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);
}
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());
}
}
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;
}
Aggregations