Search in sources :

Example 1 with BlockchainAccess

use of org.eclipse.winery.accountability.blockchain.BlockchainAccess in project winery by eclipse.

the class AccountabilityManagerImplTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    BlockchainAccess blockchainAccess = BlockchainFactory.getBlockchainAccess(BlockchainFactory.AvailableBlockchains.TEST, null);
    ImmutableStorageProvider storageProvider = ImmutableStorageProviderFactory.getStorageProvider(ImmutableStorageProviderFactory.AvailableImmutableStorages.TEST, null);
    this.provenance = new AccountabilityManagerImpl(blockchainAccess, storageProvider);
}
Also used : BlockchainAccess(org.eclipse.winery.accountability.blockchain.BlockchainAccess) ImmutableStorageProvider(org.eclipse.winery.accountability.storage.ImmutableStorageProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with BlockchainAccess

use of org.eclipse.winery.accountability.blockchain.BlockchainAccess in project winery by eclipse.

the class AccountabilityManagerImplIntegrationTest method setUp.

@BeforeEach
public void setUp() {
    AccountabilityConfigurationManager.getInstance().setDefaultKeystore();
    Environments.getInstance().getAccountabilityConfig().setEthereumPassword("winery");
    Environments.getInstance().getAccountabilityConfig().setGethUrl("http://127.0.0.1:8545");
    Environments.getInstance().getAccountabilityConfig().setSwarmGatewayUrl("https://swarm-gateways.net/");
    // deploy smart contracts to (a new address in) the blockchain
    try {
        ContractDeployer deployer = new ContractDeployer(Environments.getInstance().getAccountabilityConfig());
        Environments.getInstance().getAccountabilityConfig().setEthereumProvenanceSmartContractAddress(deployer.deployProvenance());
        Environments.getInstance().getAccountabilityConfig().setEthereumAuthorizationSmartContractAddress(deployer.deployAuthorization());
        // reset the contents of the accountability layer so older, possibly incompatible instances are nullified.
        BlockchainFactory.reset();
        ImmutableStorageProviderFactory.reset();
        // create new instances
        BlockchainAccess blockchainAccess = BlockchainFactory.getBlockchainAccess(BlockchainFactory.AvailableBlockchains.ETHEREUM, Environments.getInstance().getAccountabilityConfig());
        ImmutableStorageProvider storageProvider = ImmutableStorageProviderFactory.getStorageProvider(ImmutableStorageProviderFactory.AvailableImmutableStorages.SWARM, Environments.getInstance().getAccountabilityConfig());
        this.accountabilityManager = new AccountabilityManagerImpl(blockchainAccess, storageProvider);
    } catch (Exception e) {
        Preconditions.condition(false, e.getMessage());
    }
}
Also used : BlockchainAccess(org.eclipse.winery.accountability.blockchain.BlockchainAccess) ImmutableStorageProvider(org.eclipse.winery.accountability.storage.ImmutableStorageProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with BlockchainAccess

use of org.eclipse.winery.accountability.blockchain.BlockchainAccess in project winery by eclipse.

the class AccountabilityManagerFactory method getAccountabilityManager.

public static AccountabilityManager getAccountabilityManager() throws AccountabilityException {
    if (Objects.isNull(accountabilityManager)) {
        try {
            AccountabilityConfigurationObject properties = Environments.getInstance().getAccountabilityConfig();
            Environments.getInstance().addConfigurationChangeListener(() -> {
                BlockchainFactory.reset();
                ImmutableStorageProviderFactory.reset();
            });
            BlockchainAccess blockchain = BlockchainFactory.getBlockchainAccess(BlockchainFactory.AvailableBlockchains.ETHEREUM, properties);
            ImmutableStorageProvider storageProvider = ImmutableStorageProviderFactory.getStorageProvider(ImmutableStorageProviderFactory.AvailableImmutableStorages.SWARM, properties);
            accountabilityManager = new AccountabilityManagerImpl(blockchain, storageProvider);
        } catch (BlockchainException e) {
            String msg = "Could not instantiate accountability layer: " + e.getMessage();
            LOGGER.error(msg, e);
            throw new AccountabilityException(msg, e);
        }
    }
    return accountabilityManager;
}
Also used : BlockchainException(org.eclipse.winery.accountability.exceptions.BlockchainException) AccountabilityException(org.eclipse.winery.accountability.exceptions.AccountabilityException) BlockchainAccess(org.eclipse.winery.accountability.blockchain.BlockchainAccess) ImmutableStorageProvider(org.eclipse.winery.accountability.storage.ImmutableStorageProvider) AccountabilityConfigurationObject(org.eclipse.winery.common.configuration.AccountabilityConfigurationObject)

Aggregations

BlockchainAccess (org.eclipse.winery.accountability.blockchain.BlockchainAccess)3 ImmutableStorageProvider (org.eclipse.winery.accountability.storage.ImmutableStorageProvider)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 AccountabilityException (org.eclipse.winery.accountability.exceptions.AccountabilityException)1 BlockchainException (org.eclipse.winery.accountability.exceptions.BlockchainException)1 AccountabilityConfigurationObject (org.eclipse.winery.common.configuration.AccountabilityConfigurationObject)1