├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .gitmodules ├── .mvn ├── jvm.config └── maven-template.config ├── .shellcheckrc ├── .travis.yml ├── .travis ├── run_python_tests.sh ├── run_travis_job.sh └── skip-ci.sh ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── checkstyle.xml ├── exonum-java-binding ├── .mvn │ └── jvm.config ├── CHANGELOG.md ├── LICENSES-THIRD-PARTY.TXT ├── README.md ├── app │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ └── app │ │ │ └── ServiceRuntimeBootstrap.java │ │ └── test │ │ └── java │ │ └── com │ │ └── exonum │ │ └── binding │ │ └── app │ │ └── ServiceRuntimeBootstrapIntegrationTest.java ├── benchmarks │ ├── README.md │ └── pom.xml ├── bom │ └── pom.xml ├── common │ ├── checkstyle-suppressions.xml │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── exonum │ │ │ │ └── binding │ │ │ │ └── common │ │ │ │ ├── blockchain │ │ │ │ ├── CallInBlocks.java │ │ │ │ ├── ExecutionStatuses.java │ │ │ │ └── TransactionLocation.java │ │ │ │ ├── collect │ │ │ │ └── MapEntry.java │ │ │ │ ├── crypto │ │ │ │ ├── AbstractKey.java │ │ │ │ ├── CryptoFunction.java │ │ │ │ ├── CryptoFunctions.java │ │ │ │ ├── CryptoUtils.java │ │ │ │ ├── Ed25519CryptoFunction.java │ │ │ │ ├── KeyPair.java │ │ │ │ ├── PrivateKey.java │ │ │ │ └── PublicKey.java │ │ │ │ ├── hash │ │ │ │ ├── AbstractByteHasher.java │ │ │ │ ├── AbstractHashFunction.java │ │ │ │ ├── AbstractHasher.java │ │ │ │ ├── AbstractNonStreamingHashFunction.java │ │ │ │ ├── AbstractStreamingHasher.java │ │ │ │ ├── Funnel.java │ │ │ │ ├── Funnels.java │ │ │ │ ├── HashCode.java │ │ │ │ ├── HashFunction.java │ │ │ │ ├── Hasher.java │ │ │ │ ├── Hashing.java │ │ │ │ ├── MessageDigestHashFunction.java │ │ │ │ ├── PrimitiveSink.java │ │ │ │ └── package-info.java │ │ │ │ ├── message │ │ │ │ ├── ByteStringFunnel.java │ │ │ │ ├── ParsedTransactionMessage.java │ │ │ │ ├── SignedMessage.java │ │ │ │ └── TransactionMessage.java │ │ │ │ ├── proofs │ │ │ │ ├── CheckedProof.java │ │ │ │ ├── DbKeyCompressedFunnel.java │ │ │ │ ├── DbKeyFunnel.java │ │ │ │ ├── InvalidProofException.java │ │ │ │ ├── ProofHashes.java │ │ │ │ ├── ProofStatus.java │ │ │ │ ├── list │ │ │ │ │ ├── CheckedListProof.java │ │ │ │ │ ├── CheckedListProofImpl.java │ │ │ │ │ ├── FlatListProof.java │ │ │ │ │ ├── ListProofElementEntry.java │ │ │ │ │ ├── ListProofEntry.java │ │ │ │ │ ├── ListProofHashedEntry.java │ │ │ │ │ └── ListProofStatus.java │ │ │ │ └── map │ │ │ │ │ ├── CheckedFlatMapProof.java │ │ │ │ │ ├── CheckedMapProof.java │ │ │ │ │ ├── DbKey.java │ │ │ │ │ ├── KeyBitSet.java │ │ │ │ │ ├── MapProofEntry.java │ │ │ │ │ ├── MapProofStatus.java │ │ │ │ │ ├── UncheckedFlatMapProof.java │ │ │ │ │ └── UncheckedMapProof.java │ │ │ │ ├── runtime │ │ │ │ ├── JavaArtifactUtils.java │ │ │ │ ├── RuntimeId.java │ │ │ │ └── ServiceArtifactId.java │ │ │ │ └── serialization │ │ │ │ ├── BoolSerializer.java │ │ │ │ ├── CheckingSerializerDecorator.java │ │ │ │ ├── DoubleSerializer.java │ │ │ │ ├── Fixed32Serializer.java │ │ │ │ ├── Fixed64Serializer.java │ │ │ │ ├── FloatSerializer.java │ │ │ │ ├── HashCodeSerializer.java │ │ │ │ ├── NoOpSerializer.java │ │ │ │ ├── PrivateKeySerializer.java │ │ │ │ ├── ProtobufReflectiveSerializer.java │ │ │ │ ├── PublicKeySerializer.java │ │ │ │ ├── SerializationUtils.java │ │ │ │ ├── Serializer.java │ │ │ │ ├── Sint32Serializer.java │ │ │ │ ├── Sint64Serializer.java │ │ │ │ ├── StandardSerializers.java │ │ │ │ ├── StringSerializer.java │ │ │ │ ├── TransactionMessageSerializer.java │ │ │ │ ├── Uint32Serializer.java │ │ │ │ ├── Uint64Serializer.java │ │ │ │ └── json │ │ │ │ ├── CommonTypeAdapterFactory.java │ │ │ │ ├── HashCodeJsonSerializer.java │ │ │ │ ├── JsonSerializer.java │ │ │ │ ├── PublicKeyJsonSerializer.java │ │ │ │ ├── TransactionMessageJsonSerializer.java │ │ │ │ └── ZonedDateTimeJsonSerializer.java │ │ └── proto │ │ │ └── exonum │ │ │ └── java │ │ │ ├── deploy_arguments.proto │ │ │ └── service.proto │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ ├── common │ │ │ ├── blockchain │ │ │ │ ├── CallInBlocksTest.java │ │ │ │ └── ExecutionStatusesTest.java │ │ │ ├── crypto │ │ │ │ ├── AbstractKeyTest.java │ │ │ │ ├── CryptoUtilsTest.java │ │ │ │ ├── Ed25519CryptoFunctionTestable.java │ │ │ │ ├── Ed25519CryptoFunctionWithBundledTest.java │ │ │ │ ├── Ed25519CryptoFunctionWithSystemSodiumTest.java │ │ │ │ └── Forked.java │ │ │ ├── hash │ │ │ │ ├── AbstractByteHasherTest.java │ │ │ │ ├── AbstractNonStreamingHashFunctionTest.java │ │ │ │ ├── AbstractStreamingHasherTest.java │ │ │ │ ├── FunnelsTest.java │ │ │ │ ├── HashCodeTest.java │ │ │ │ ├── HashTestUtils.java │ │ │ │ ├── HashingTest.java │ │ │ │ └── MessageDigestHashFunctionTest.java │ │ │ ├── message │ │ │ │ ├── ByteStringFunnelTest.java │ │ │ │ ├── ParsedTransactionMessageTest.java │ │ │ │ ├── SignedMessageTest.java │ │ │ │ └── TransactionMessageBuilderTest.java │ │ │ ├── proofs │ │ │ │ ├── DbKeyCompressedFunnelTest.java │ │ │ │ ├── ProofHashesTest.java │ │ │ │ ├── list │ │ │ │ │ ├── FlatListProofTest.java │ │ │ │ │ └── ListProofUtils.java │ │ │ │ └── map │ │ │ │ │ ├── DbKeyCommonPrefixParameterizedTest.java │ │ │ │ │ ├── DbKeyComparisonParameterizedTest.java │ │ │ │ │ ├── DbKeyTest.java │ │ │ │ │ ├── DbKeyTestUtils.java │ │ │ │ │ ├── KeyBitSetIsPrefixParameterizedTest.java │ │ │ │ │ ├── MapEntryTest.java │ │ │ │ │ └── UncheckedFlatMapProofTest.java │ │ │ ├── runtime │ │ │ │ ├── JavaArtifactUtilsTest.java │ │ │ │ └── ServiceArtifactIdTest.java │ │ │ └── serialization │ │ │ │ ├── BoolSerializerTest.java │ │ │ │ ├── CheckingSerializerDecoratorTest.java │ │ │ │ ├── DoubleSerializerTest.java │ │ │ │ ├── Fixed32SerializerTest.java │ │ │ │ ├── Fixed64SerializerTest.java │ │ │ │ ├── FloatSerializerTest.java │ │ │ │ ├── HashCodeSerializerTest.java │ │ │ │ ├── NoOpSerializerTest.java │ │ │ │ ├── PrivateKeySerializerTest.java │ │ │ │ ├── ProtobufReflectiveSerializerTest.java │ │ │ │ ├── PublicKeySerializerTest.java │ │ │ │ ├── Sint32SerializerTest.java │ │ │ │ ├── Sint64SerializerTest.java │ │ │ │ ├── StandardSerializersTestUtils.java │ │ │ │ ├── StringSerializerTest.java │ │ │ │ ├── TransactionMessageSerializerTest.java │ │ │ │ ├── Uint32SerializerTest.java │ │ │ │ ├── Uint64SerializerTest.java │ │ │ │ └── json │ │ │ │ ├── JsonSerializerTest.java │ │ │ │ ├── TransactionMessageGsonSerializerTest.java │ │ │ │ └── ZonedDateTimeGsonSerializerTest.java │ │ │ └── test │ │ │ ├── EqualsTester.java │ │ │ └── RelationshipTester.java │ │ └── proto │ │ └── TestMessage.proto ├── core │ ├── checkstyle-suppressions.xml │ ├── pom.xml │ ├── rust │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── exonum-java │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ ├── exonum-java │ │ │ ├── log4j-fallback.xml │ │ │ ├── qa-service.yml │ │ │ ├── src │ │ │ │ ├── main.rs │ │ │ │ └── node.rs │ │ │ └── start_node.sh │ │ ├── generate_licenses.sh │ │ ├── integration_tests │ │ │ ├── Cargo.toml │ │ │ ├── benches │ │ │ │ ├── example_atomic_integer_proxy.rs │ │ │ │ └── jni_cache.rs │ │ │ ├── log4j2.xml │ │ │ ├── src │ │ │ │ ├── example_proxy.rs │ │ │ │ ├── lib.rs │ │ │ │ └── vm.rs │ │ │ └── tests │ │ │ │ ├── jni_cache.rs │ │ │ │ ├── jni_cache_not_initialized.rs │ │ │ │ ├── local_frame_capacity.rs │ │ │ │ ├── local_frame_memory_leak_executor.rs │ │ │ │ ├── local_frame_memory_leak_jvm.rs │ │ │ │ ├── node_context.rs │ │ │ │ ├── runtime_bootstrap.rs │ │ │ │ ├── runtime_error_handling.rs │ │ │ │ └── utils_errors.rs │ │ └── src │ │ │ ├── cmd │ │ │ ├── mod.rs │ │ │ ├── run.rs │ │ │ └── run_dev.rs │ │ │ ├── handle │ │ │ ├── mod.rs │ │ │ └── resource_manager │ │ │ │ ├── imp.rs │ │ │ │ ├── mod.rs │ │ │ │ └── stub.rs │ │ │ ├── lib.rs │ │ │ ├── proto │ │ │ └── mod.rs │ │ │ ├── proxy │ │ │ ├── mod.rs │ │ │ ├── node.rs │ │ │ └── runtime.rs │ │ │ ├── runtime │ │ │ ├── config.rs │ │ │ ├── error.rs │ │ │ ├── java_runtime_factory.rs │ │ │ ├── library_loader.rs │ │ │ ├── mod.rs │ │ │ └── paths.rs │ │ │ ├── storage │ │ │ ├── access.rs │ │ │ ├── blockchain.rs │ │ │ ├── blockchain_data.rs │ │ │ ├── entry.rs │ │ │ ├── fork.rs │ │ │ ├── key_set_index.rs │ │ │ ├── list_index.rs │ │ │ ├── map_index.rs │ │ │ ├── mod.rs │ │ │ ├── pair_iter.rs │ │ │ ├── prefixed.rs │ │ │ ├── proof_entry.rs │ │ │ ├── proof_list_index.rs │ │ │ ├── proof_map_index.rs │ │ │ ├── proof_map_index_next.rs │ │ │ ├── raw_proof_map_index.rs │ │ │ ├── readonly_erased_access.rs │ │ │ ├── temporarydb.rs │ │ │ └── value_set_index.rs │ │ │ ├── testkit │ │ │ ├── mod.rs │ │ │ └── time_provider.rs │ │ │ └── utils │ │ │ ├── conversion.rs │ │ │ ├── errors.rs │ │ │ ├── jni.rs │ │ │ ├── jni_cache.rs │ │ │ └── mod.rs │ ├── spotbugs-exclude.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── exonum │ │ │ │ └── binding │ │ │ │ └── core │ │ │ │ ├── annotations │ │ │ │ ├── AutoGenerationCandidate.java │ │ │ │ └── ImproveDocs.java │ │ │ │ ├── blockchain │ │ │ │ ├── Block.java │ │ │ │ ├── Blockchain.java │ │ │ │ ├── BlockchainData.java │ │ │ │ ├── BlockchainProofs.java │ │ │ │ ├── CallRecords.java │ │ │ │ ├── CoreSchema.java │ │ │ │ ├── proofs │ │ │ │ │ ├── BlockProof.java │ │ │ │ │ └── IndexProof.java │ │ │ │ └── serialization │ │ │ │ │ ├── BlockSerializer.java │ │ │ │ │ ├── CoreTypeAdapterFactory.java │ │ │ │ │ └── TransactionLocationSerializer.java │ │ │ │ ├── proxy │ │ │ │ ├── AbstractCloseableNativeProxy.java │ │ │ │ ├── AbstractNativeProxy.java │ │ │ │ ├── CancellableCleanAction.java │ │ │ │ ├── CleanAction.java │ │ │ │ ├── Cleaner.java │ │ │ │ ├── CloseFailuresException.java │ │ │ │ ├── CloseableNativeProxy.java │ │ │ │ ├── FrequencyStatsFormatter.java │ │ │ │ ├── NativeHandle.java │ │ │ │ └── ProxyDestructor.java │ │ │ │ ├── runtime │ │ │ │ ├── AccessFactory.java │ │ │ │ ├── AccessProxyFactory.java │ │ │ │ ├── BlockchainDataFactory.java │ │ │ │ ├── ClassLoadingScopeChecker.java │ │ │ │ ├── DispatcherSchema.java │ │ │ │ ├── FrameworkModule.java │ │ │ │ ├── GuiceServicesFactory.java │ │ │ │ ├── JarPluginManager.java │ │ │ │ ├── LoadedServiceDefinition.java │ │ │ │ ├── NodeProxy.java │ │ │ │ ├── Pf4jServiceLoader.java │ │ │ │ ├── ReflectiveModuleSupplier.java │ │ │ │ ├── RuntimeModule.java │ │ │ │ ├── RuntimeTransport.java │ │ │ │ ├── ServiceConfiguration.java │ │ │ │ ├── ServiceFrameworkModule.java │ │ │ │ ├── ServiceInstanceSpec.java │ │ │ │ ├── ServiceLoader.java │ │ │ │ ├── ServiceLoadingException.java │ │ │ │ ├── ServiceNodeProxy.java │ │ │ │ ├── ServiceRuntime.java │ │ │ │ ├── ServiceRuntimeAdapter.java │ │ │ │ ├── ServiceWrapper.java │ │ │ │ ├── ServicesFactory.java │ │ │ │ ├── TransactionExtractor.java │ │ │ │ ├── TransactionInvoker.java │ │ │ │ ├── TransactionMethod.java │ │ │ │ └── UnexpectedExecutionException.java │ │ │ │ ├── service │ │ │ │ ├── AbstractService.java │ │ │ │ ├── AbstractServiceModule.java │ │ │ │ ├── BlockCommittedEvent.java │ │ │ │ ├── BlockCommittedEventImpl.java │ │ │ │ ├── Configurable.java │ │ │ │ ├── Configuration.java │ │ │ │ ├── ExecutionContext.java │ │ │ │ ├── ExecutionException.java │ │ │ │ ├── ExecutionPreconditions.java │ │ │ │ ├── InternalExecutionContext.java │ │ │ │ ├── Node.java │ │ │ │ ├── NodeFake.java │ │ │ │ ├── Schema.java │ │ │ │ ├── Service.java │ │ │ │ ├── ServiceModule.java │ │ │ │ ├── TransactionSubmissionException.java │ │ │ │ └── adapters │ │ │ │ │ └── package-info.java │ │ │ │ ├── storage │ │ │ │ ├── database │ │ │ │ │ ├── AbstractAccess.java │ │ │ │ │ ├── Access.java │ │ │ │ │ ├── Database.java │ │ │ │ │ ├── Fork.java │ │ │ │ │ ├── OpenIndexRegistry.java │ │ │ │ │ ├── Prefixed.java │ │ │ │ │ ├── RoErasedAccess.java │ │ │ │ │ ├── Snapshot.java │ │ │ │ │ └── TemporaryDb.java │ │ │ │ └── indices │ │ │ │ │ ├── AbstractEntryIndexProxy.java │ │ │ │ │ ├── AbstractIndexProxy.java │ │ │ │ │ ├── AbstractListIndexProxy.java │ │ │ │ │ ├── ConfigurableRustIter.java │ │ │ │ │ ├── EntryIndex.java │ │ │ │ │ ├── EntryIndexProxy.java │ │ │ │ │ ├── HashableIndex.java │ │ │ │ │ ├── ImmutableModificationCounter.java │ │ │ │ │ ├── IncrementalModificationCounter.java │ │ │ │ │ ├── IndexAddress.java │ │ │ │ │ ├── KeySetIndexProxy.java │ │ │ │ │ ├── ListIndex.java │ │ │ │ │ ├── ListIndexProxy.java │ │ │ │ │ ├── ListProof.java │ │ │ │ │ ├── ListSpliterator.java │ │ │ │ │ ├── MapEntryInternal.java │ │ │ │ │ ├── MapIndex.java │ │ │ │ │ ├── MapIndexProxy.java │ │ │ │ │ ├── MapProof.java │ │ │ │ │ ├── ModificationCounter.java │ │ │ │ │ ├── ProofEntryIndex.java │ │ │ │ │ ├── ProofEntryIndexProxy.java │ │ │ │ │ ├── ProofListIndexProxy.java │ │ │ │ │ ├── ProofMapIndexProxy.java │ │ │ │ │ ├── ProofMapKeyCheckingSerializerDecorator.java │ │ │ │ │ ├── RustIter.java │ │ │ │ │ ├── RustIterAdapter.java │ │ │ │ │ ├── StorageIndex.java │ │ │ │ │ ├── StorageIterators.java │ │ │ │ │ ├── StoragePreconditions.java │ │ │ │ │ ├── ValueSetIndexProxy.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── transaction │ │ │ │ ├── RawTransaction.java │ │ │ │ └── Transaction.java │ │ │ │ ├── transport │ │ │ │ ├── Server.java │ │ │ │ └── VertxServer.java │ │ │ │ └── util │ │ │ │ ├── LibraryLoader.java │ │ │ │ └── OsInfo.java │ │ └── proto │ │ │ └── exonum │ │ │ └── testkit │ │ │ └── testkit.proto │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ └── core │ │ │ ├── blockchain │ │ │ ├── BlockTest.java │ │ │ ├── BlockchainDataIntegrationTest.java │ │ │ ├── Blocks.java │ │ │ ├── CoreSchemaIntegrationTest.java │ │ │ └── serialization │ │ │ │ ├── BlockSerializerTest.java │ │ │ │ └── TransactionLocationSerializerTest.java │ │ │ ├── proxy │ │ │ ├── AbstractCloseableNativeProxyTest.java │ │ │ ├── CleanerTest.java │ │ │ ├── DefaultCleanActionTest.java │ │ │ ├── FrequencyStatsFormatterTest.java │ │ │ ├── NativeHandleTest.java │ │ │ └── ProxyDestructorTest.java │ │ │ ├── runtime │ │ │ ├── ClassLoadingScopeCheckerTest.java │ │ │ ├── EvilPluginFailingToStart.java │ │ │ ├── GuiceServicesFactoryTest.java │ │ │ ├── JarPluginManagerSmokeIntegrationTest.java │ │ │ ├── Pf4jServiceLoaderIntegrationTestable.java │ │ │ ├── Pf4jServiceLoaderWithDefaultIntegrationTest.java │ │ │ ├── Pf4jServiceLoaderWithJarIntegrationTest.java │ │ │ ├── ReflectiveModuleSupplierTest.java │ │ │ ├── RuntimeTransportTest.java │ │ │ ├── ServiceConfigurationTest.java │ │ │ ├── ServiceNodeProxyIntegrationTest.java │ │ │ ├── ServiceRuntimeAdapterIntegrationTest.java │ │ │ ├── ServiceRuntimeConfigurationIntegrationTest.java │ │ │ ├── ServiceRuntimeIntegrationTest.java │ │ │ ├── ServiceWrapperIntegrationTest.java │ │ │ ├── TestService.java │ │ │ ├── TestServiceModule.java │ │ │ ├── TestServiceModule1.java │ │ │ ├── TestServiceModule2.java │ │ │ ├── TestServiceModuleInaccessibleCtor.java │ │ │ ├── TransactionExtractorTest.java │ │ │ └── TransactionInvokerTest.java │ │ │ ├── service │ │ │ └── AbstractServiceTest.java │ │ │ ├── storage │ │ │ ├── database │ │ │ │ ├── ForkIntegrationTest.java │ │ │ │ ├── ForkTest.java │ │ │ │ ├── NativeResourceManagerIntegrationTest.java │ │ │ │ ├── OpenIndexRegistryTest.java │ │ │ │ ├── PrefixedIntegrationTest.java │ │ │ │ ├── RoErasedAccessIntegrationTest.java │ │ │ │ ├── SnapshotTest.java │ │ │ │ └── TemporaryDbIntegrationTest.java │ │ │ └── indices │ │ │ │ ├── AbstractIndexProxyTest.java │ │ │ │ ├── BaseEntryIndexProxyIntegrationTest.java │ │ │ │ ├── BaseIndexGroupTestable.java │ │ │ │ ├── BaseIndexProxyTestable.java │ │ │ │ ├── BaseListIndexIntegrationTestable.java │ │ │ │ ├── BaseListIndexProxyGroupTestable.java │ │ │ │ ├── BaseMapIndexGroupTestable.java │ │ │ │ ├── BaseProofMapIndexProxyIntegrationTestable.java │ │ │ │ ├── CheckedMapProofMatcher.java │ │ │ │ ├── CheckedMapProofMatcherTest.java │ │ │ │ ├── ConfigurableRustIterTest.java │ │ │ │ ├── DisabledProofTest.java │ │ │ │ ├── EntryIndexProxyIntegrationTest.java │ │ │ │ ├── ImmutableModificationCounterTest.java │ │ │ │ ├── IncrementalModificationCounterTest.java │ │ │ │ ├── IndexAddressTest.java │ │ │ │ ├── IndexConstructorOne.java │ │ │ │ ├── IndicesTests.java │ │ │ │ ├── KeySetIndexProxyGroupIntegrationTest.java │ │ │ │ ├── KeySetIndexProxyIntegrationTest.java │ │ │ │ ├── ListIndexProxyGroupIntegrationTest.java │ │ │ │ ├── ListIndexProxyIntegrationTest.java │ │ │ │ ├── ListSpliteratorTest.java │ │ │ │ ├── MapEntries.java │ │ │ │ ├── MapIndexProxyGroupIntegrationTest.java │ │ │ │ ├── MapIndexProxyIntegrationTest.java │ │ │ │ ├── MapTestEntry.java │ │ │ │ ├── ProofEntryIndexProxyIntegrationTest.java │ │ │ │ ├── ProofListContainsMatcher.java │ │ │ │ ├── ProofListIndexProxyGroupIntegrationTest.java │ │ │ │ ├── ProofListIndexProxyIntegrationTest.java │ │ │ │ ├── ProofMapContainsMatcher.java │ │ │ │ ├── ProofMapIndexProxyGroupIntegrationTest.java │ │ │ │ ├── ProofMapIndexProxyGroupNoKeyHashingIntegrationTest.java │ │ │ │ ├── ProofMapIndexProxyIntegrationTest.java │ │ │ │ ├── ProofMapIndexProxyNoKeyHashingIntegrationTest.java │ │ │ │ ├── RustIterAdapterTest.java │ │ │ │ ├── RustIterTestFake.java │ │ │ │ ├── StoragePreconditionsTest.java │ │ │ │ ├── TestStorageItems.java │ │ │ │ ├── ValueSetIndexProxyGroupIntegrationTest.java │ │ │ │ └── ValueSetIndexProxyIntegrationTest.java │ │ │ ├── transaction │ │ │ ├── ExecutionExceptionTest.java │ │ │ ├── ExecutionPreconditionsTest.java │ │ │ └── RawTransactionTest.java │ │ │ └── transport │ │ │ └── VertxServerIntegrationTest.java │ │ ├── proto │ │ └── TestMessages.proto │ │ └── resources │ │ ├── log4j2-test.xml │ │ └── mockito-extensions │ │ └── org.mockito.plugins.MockMaker ├── cryptocurrency-demo │ ├── Readme.md │ ├── checkstyle-suppressions.xml │ ├── cryptocurrency-demo.yml │ ├── frontend │ │ ├── .babelrc │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── favicon.ico │ │ ├── images │ │ │ ├── exonum.png │ │ │ └── spinner.gif │ │ ├── index.html │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── server.js │ │ ├── src │ │ │ ├── App.vue │ │ │ ├── app.js │ │ │ ├── components │ │ │ │ ├── Modal.vue │ │ │ │ ├── Navbar.vue │ │ │ │ ├── Spinner.vue │ │ │ │ ├── Tab.vue │ │ │ │ ├── Tabs.vue │ │ │ │ └── WalletHistory.vue │ │ │ ├── directives │ │ │ │ └── numeral.js │ │ │ ├── pages │ │ │ │ ├── Auth.vue │ │ │ │ ├── Block.vue │ │ │ │ ├── Blockchain.vue │ │ │ │ ├── Transaction.vue │ │ │ │ └── Wallet.vue │ │ │ ├── plugins │ │ │ │ ├── blockchain.js │ │ │ │ ├── notify.js │ │ │ │ └── validate.js │ │ │ ├── proto │ │ │ │ └── .gitkeep │ │ │ ├── router │ │ │ │ └── index.js │ │ │ └── store │ │ │ │ └── index.js │ │ ├── tests │ │ │ └── blockchain.test.js │ │ └── webpack.config.js │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── exonum │ │ │ │ │ └── binding │ │ │ │ │ └── cryptocurrency │ │ │ │ │ ├── ApiController.java │ │ │ │ │ ├── CryptocurrencySchema.java │ │ │ │ │ ├── CryptocurrencyService.java │ │ │ │ │ ├── CryptocurrencyServiceImpl.java │ │ │ │ │ ├── CryptocurrencyServiceModule.java │ │ │ │ │ ├── HistoryEntity.java │ │ │ │ │ ├── TransactionError.java │ │ │ │ │ ├── Wallet.java │ │ │ │ │ └── WalletSerializer.java │ │ │ └── proto │ │ │ │ ├── transactions.proto │ │ │ │ └── wallet.proto │ │ └── test │ │ │ ├── java │ │ │ └── com │ │ │ │ └── exonum │ │ │ │ └── binding │ │ │ │ └── cryptocurrency │ │ │ │ ├── ApiControllerTest.java │ │ │ │ ├── CreateWalletTxIntegrationTest.java │ │ │ │ ├── CryptocurrencySchemaIntegrationTest.java │ │ │ │ ├── PredefinedOwnerKeys.java │ │ │ │ ├── PredefinedServiceParameters.java │ │ │ │ ├── TransactionUtils.java │ │ │ │ ├── TransferTxHistoryIntegrationTest.java │ │ │ │ ├── TransferTxIntegrationTest.java │ │ │ │ └── WalletSerializerTest.java │ │ │ └── resources │ │ │ ├── log4j2-test.xml │ │ │ └── mockito-extensions │ │ │ └── org.mockito.plugins.MockMaker │ └── start-node.sh ├── doc │ ├── Migration_guide_0.10.md │ ├── Migration_guide_0.4.md │ ├── Migration_guide_0.6.md │ ├── Migration_guide_0.7.md │ └── Migration_guide_0.9.md ├── exonum_launcher_java_plugins │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── exonum_instance_configuration_plugin │ │ ├── __init__.py │ │ └── plugin.py │ ├── exonum_java_runtime_plugin │ │ ├── __init__.py │ │ └── plugin.py │ ├── requirements.txt │ ├── sample-config.yml │ ├── setup.py │ └── tests │ │ ├── __init__.py │ │ ├── test_data │ │ ├── config.json │ │ ├── config.properties │ │ ├── config.txt │ │ ├── custom_message_name.yml │ │ ├── instance_plugin.yml │ │ ├── invalid_config.yml │ │ ├── proto_sources │ │ │ ├── custom_message_name.proto │ │ │ └── timestamping.proto │ │ ├── standard_message_json.yml │ │ ├── standard_message_properties.yml │ │ └── standard_message_text.yml │ │ └── test_instance_plugin.py ├── fake-service │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── exonum │ │ │ │ └── binding │ │ │ │ └── fakeservice │ │ │ │ ├── FakeSchema.java │ │ │ │ ├── FakeService.java │ │ │ │ └── FakeServiceModule.java │ │ └── proto │ │ │ └── transactions.proto │ │ └── test │ │ └── java │ │ └── com │ │ └── exonum │ │ └── binding │ │ └── fakeservice │ │ └── FakeServiceModuleTest.java ├── generate-javadocs.sh ├── integration-tests │ ├── checkstyle-suppressions.xml │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ └── test │ │ │ ├── BlockchainDataIntegrationTest.java │ │ │ ├── BlockchainIntegrationTest.java │ │ │ ├── ServiceRuntimeIntegrationTest.java │ │ │ ├── TestArtifactInfo.java │ │ │ └── TimeSchemaProxyIntegrationTest.java │ │ └── resources │ │ └── log4j2-test.xml ├── messages │ └── pom.xml ├── package_app.sh ├── packaging │ ├── app_assembly.xml │ └── pom.xml ├── pom.xml ├── qa-service │ ├── checkstyle-suppressions.xml │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── exonum │ │ │ │ └── binding │ │ │ │ └── qaservice │ │ │ │ ├── ApiController.java │ │ │ │ ├── Counter.java │ │ │ │ ├── QaExecutionError.java │ │ │ │ ├── QaSchema.java │ │ │ │ ├── QaService.java │ │ │ │ ├── QaServiceImpl.java │ │ │ │ ├── QaServiceModule.java │ │ │ │ └── TimeDto.java │ │ └── proto │ │ │ ├── config.proto │ │ │ └── transactions.proto │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ └── qaservice │ │ │ ├── ApiControllerTest.java │ │ │ ├── CounterTest.java │ │ │ ├── CreateCounterTxTest.java │ │ │ ├── ErrorTxTest.java │ │ │ ├── IncrementCounterTxTest.java │ │ │ ├── QaArtifactInfo.java │ │ │ ├── QaServiceImplTest.java │ │ │ ├── ThrowingTxTest.java │ │ │ ├── TransactionMessages.java │ │ │ └── TransactionUtils.java │ │ └── resources │ │ ├── log4j2-test.xml │ │ └── mockito-extensions │ │ └── org.mockito.plugins.MockMaker ├── run_all_tests.sh ├── run_app_tests.sh ├── run_maven_tests.sh ├── run_native_integration_tests.sh ├── run_tutorials_tests.sh ├── service-archetype │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── resources-filtered │ │ │ └── archetype-resources │ │ │ │ ├── __rootArtifactId__-messages │ │ │ │ └── pom.xml │ │ │ │ ├── __rootArtifactId__-service │ │ │ │ └── pom.xml │ │ │ │ └── pom.xml │ │ └── resources │ │ │ ├── META-INF │ │ │ └── maven │ │ │ │ └── archetype-metadata.xml │ │ │ └── archetype-resources │ │ │ ├── README.md │ │ │ ├── __rootArtifactId__-messages │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── proto │ │ │ │ └── .gitkeep │ │ │ ├── __rootArtifactId__-service │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ ├── MySchema.java │ │ │ │ │ ├── MyService.java │ │ │ │ │ └── ServiceModule.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── MyServiceIntegrationTest.java │ │ │ ├── deploy-start-config.yml │ │ │ └── start-testnet.sh │ │ └── test │ │ └── resources │ │ └── projects │ │ ├── archetype.properties │ │ └── goal.txt ├── site-examples │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── exonum │ │ │ │ └── binding │ │ │ │ └── example │ │ │ │ └── guide │ │ │ │ ├── FooSchema.java │ │ │ │ ├── FooService.java │ │ │ │ ├── ProofMapCreation.java │ │ │ │ └── ServiceModule.java │ │ └── proto │ │ │ └── example │ │ │ └── guide │ │ │ └── transactions.proto │ │ └── test │ │ └── java │ │ └── com │ │ └── exonum │ │ └── binding │ │ └── example │ │ └── testing │ │ ├── IntegrationTestArguments.java │ │ ├── TestkitExamples2Test.java │ │ └── TestkitExamplesTest.java ├── testing │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ └── test │ │ │ ├── Bytes.java │ │ │ ├── CiOnly.java │ │ │ ├── Integration.java │ │ │ ├── RequiresNativeLibrary.java │ │ │ └── runtime │ │ │ └── ServiceArtifactBuilder.java │ │ └── test │ │ └── java │ │ └── com │ │ └── exonum │ │ └── binding │ │ └── test │ │ ├── BytesTest.java │ │ └── runtime │ │ ├── ServiceArtifactBuilderSmokeIntegrationTest.java │ │ ├── ServiceArtifactBuilderTest.java │ │ ├── TestService.java │ │ └── testplugin │ │ ├── TestPlugin.java │ │ ├── TestServiceExtension.java │ │ └── TestServiceExtensionImpl.java ├── testkit │ ├── README.md │ ├── checkstyle-suppressions.xml │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ └── testkit │ │ │ ├── Auditor.java │ │ │ ├── EmulatedNode.java │ │ │ ├── EmulatedNodeType.java │ │ │ ├── FakeTimeProvider.java │ │ │ ├── TestKit.java │ │ │ ├── TestKitExtension.java │ │ │ ├── TimeProvider.java │ │ │ ├── TimeProviderAdapter.java │ │ │ ├── TimeServiceSpec.java │ │ │ ├── Validator.java │ │ │ └── ValidatorCount.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ └── testkit │ │ │ ├── FakeTimeProviderTest.java │ │ │ ├── SystemTimeProviderTest.java │ │ │ ├── TestKitAuditorParameterizationTest.java │ │ │ ├── TestKitExtensionTest.java │ │ │ ├── TestKitParameterizationTest.java │ │ │ ├── TestKitTest.java │ │ │ ├── TestKitTestUtils.java │ │ │ ├── TestSchema.java │ │ │ ├── TestService.java │ │ │ ├── TestService2.java │ │ │ ├── TestServiceModule.java │ │ │ └── TestServiceModule2.java │ │ └── proto │ │ ├── TestMessages.proto │ │ └── transactions.proto ├── tests_profile ├── time-oracle │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── exonum │ │ │ └── binding │ │ │ └── time │ │ │ ├── TimeSchema.java │ │ │ ├── TimeSchemaProxy.java │ │ │ └── UtcZonedDateTimeSerializer.java │ │ └── test │ │ └── java │ │ └── com │ │ └── exonum │ │ └── binding │ │ └── time │ │ └── UtcZonedDateTimeSerializerTest.java └── tutorials │ ├── car-registry │ ├── .gitignore │ ├── README.md │ ├── car-registry-client │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── car │ │ │ └── client │ │ │ ├── AbstractSubmitTxCommand.java │ │ │ ├── AddVehicleCommand.java │ │ │ ├── ChangeOwnerCommand.java │ │ │ ├── Config.java │ │ │ ├── FindVehicleCommand.java │ │ │ ├── GenerateKeyCommand.java │ │ │ ├── Main.java │ │ │ ├── ServiceIdResolver.java │ │ │ └── ServiceIds.java │ ├── car-registry-messages │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── proto │ │ │ ├── .gitkeep │ │ │ └── example │ │ │ └── vehicle │ │ │ ├── transactions.proto │ │ │ └── vehicle.proto │ ├── car-registry-service │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── car │ │ │ │ ├── ApiController.java │ │ │ │ ├── MySchema.java │ │ │ │ ├── MyService.java │ │ │ │ └── ServiceModule.java │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── car │ │ │ └── MyServiceIntegrationTest.java │ ├── deploy-start-config.yml │ ├── pom.xml │ └── start-testnet.sh │ └── pom.xml ├── exonum-light-client ├── .mvn │ └── jvm.config ├── CHANGELOG.md ├── README.md ├── checkstyle-suppressions.xml ├── generate-javadocs.sh ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── exonum │ │ │ └── client │ │ │ ├── ExonumApi.java │ │ │ ├── ExonumClient.java │ │ │ ├── ExonumHttpClient.java │ │ │ ├── ExonumIterables.java │ │ │ ├── ExonumUrls.java │ │ │ ├── ExplorerApiHelper.java │ │ │ ├── HttpUrlHelper.java │ │ │ ├── package-info.java │ │ │ ├── request │ │ │ ├── BlockFilteringOption.java │ │ │ └── BlockTimeOption.java │ │ │ └── response │ │ │ └── TransactionStatus.java │ └── lombok │ │ └── com │ │ └── exonum │ │ └── client │ │ └── response │ │ ├── Block.java │ │ ├── BlockResponse.java │ │ ├── BlocksRange.java │ │ ├── BlocksResponse.java │ │ ├── ServiceInstanceInfo.java │ │ ├── ServiceInstanceState.java │ │ ├── ServicesResponse.java │ │ └── TransactionResponse.java │ └── test │ └── java │ └── com │ └── exonum │ └── client │ ├── Blocks.java │ ├── ExonumHttpClientBlocksIntegrationTest.java │ ├── ExonumHttpClientIntegrationTest.java │ ├── ExonumHttpClientWithPrefixIntegrationTest.java │ ├── ExonumIterablesTest.java │ ├── ExplorerApiHelperTest.java │ ├── HttpUrlHelperTest.java │ ├── RecordedRequestMatchers.java │ ├── TestUtils.java │ └── response │ ├── BlockTest.java │ ├── BlocksRangeTest.java │ └── TransactionResponseTest.java ├── package-lock.json ├── pom.xml └── run_all_tests.sh /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | 4 | --- 5 | See: https://jira.bf.local/browse/ECR-XYZ 6 | 7 | ### Definition of Done 8 | 9 | - [ ] There are no TODOs left in the code 10 | - [ ] Change is covered by automated [tests](https://github.com/exonum/exonum-java-binding/blob/master/CONTRIBUTING.md#tests) 11 | - [ ] The [coding guidelines](https://github.com/exonum/exonum-java-binding/blob/master/CONTRIBUTING.md#the-code-style) are followed 12 | - [ ] Public API has Javadoc 13 | - [ ] Method preconditions are checked and documented in the Javadoc of the method 14 | - [ ] Changelog is updated if needed (in case of notable or breaking changes) 15 | - [ ] The continuous integration build passes 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # classes 2 | bin/ 3 | 4 | # IDE files 5 | .classpath 6 | .project 7 | .settings 8 | 9 | # Intellij IDEA files 10 | .idea 11 | **/*.iml 12 | out/ 13 | 14 | # macos files 15 | *.DS_Store 16 | 17 | # Rust stuff 18 | **/*.rs.bk 19 | .cargo/ 20 | 21 | # Maven and Rust target dirs 22 | target/ 23 | 24 | # Ignore Maven command-line configuration (we currently consider it as local). 25 | # See `mvn --help` for a list of flags to put in that file, and also 26 | # https://maven.apache.org/configure.html 27 | **/.mvn/maven.config 28 | 29 | *.log 30 | 31 | ### Java template 32 | # Compiled class file 33 | *.class 34 | 35 | # Package Files # 36 | *.jar 37 | *.war 38 | *.ear 39 | *.zip 40 | *.tar.gz 41 | *.rar 42 | 43 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 44 | hs_err_pid* 45 | 46 | # jenv configuration file 47 | **/.java-version 48 | 49 | # VS Code workspace configuration 50 | .vscode/ 51 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "proto-sources"] 2 | path = exonum-java-binding/messages/src/main/proto 3 | url = https://github.com/exonum/exonum-proto-sources.git 4 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -XX:TieredStopAtLevel=1 -XX:+UseParallelGC -------------------------------------------------------------------------------- /.mvn/maven-template.config: -------------------------------------------------------------------------------- 1 | --threads 1C -Djunit.jupiter.execution.parallel.enabled=true -Djunit.jupiter.execution.parallel.mode.default=concurrent -------------------------------------------------------------------------------- /.shellcheckrc: -------------------------------------------------------------------------------- 1 | # See https://github.com/koalaman/shellcheck/wiki/Checks 2 | 3 | # Allow 'which' usage 4 | disable=SC2230 5 | 6 | # Suppress "Not following: ./tests_profile: openBinaryFile: does not exist (No such file or directory)" 7 | disable=SC1091 8 | -------------------------------------------------------------------------------- /.travis/run_python_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs unit tests of exonum_launcher_java_plugins. 3 | 4 | # Fail immediately in case of errors and/or unset variables 5 | set -eu -o pipefail 6 | 7 | # Echo commands so that the progress can be seen in CI server logs. 8 | set -x 9 | 10 | cd "${TRAVIS_BUILD_DIR}/exonum-java-binding" 11 | 12 | # Generate protobuf files needed for plugins 13 | RUSTFLAGS="none" mvn install -DskipTests -pl common -am 14 | 15 | cd "exonum_launcher_java_plugins" 16 | 17 | # Install pip 18 | curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py 19 | python3.7 get-pip.py --user 20 | 21 | # Install dependencies 22 | pip3 install --user -r requirements.txt --no-binary=protobuf 23 | 24 | # Install exonum_launcher_java_plugins 25 | pip3 install --user -e . 26 | 27 | # Download the latest protobuf compiler 28 | PROTOC_VERSION="3.11.3" 29 | PROTOC_ZIP_FILENAME="protoc-${PROTOC_VERSION}-linux-x86_64.zip" 30 | wget "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP_FILENAME}" 31 | unzip "${PROTOC_ZIP_FILENAME}" 32 | PROTOC="$(pwd)/bin/protoc" 33 | export PROTOC="${PROTOC}" 34 | 35 | # Run tests 36 | cd tests 37 | python3.7 -m unittest -v 38 | -------------------------------------------------------------------------------- /.travis/skip-ci.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Stops the build if only markdown files were updated. 3 | # If TRAVIS_COMMIT_RANGE env variable is not set, does nothing. 4 | 5 | if [ -z "${TRAVIS_COMMIT_RANGE+x}" ]; 6 | then 7 | echo "TRAVIS_COMMIT_RANGE is not set." 8 | elif ! git diff --name-only "${TRAVIS_COMMIT_RANGE}" | grep -qvE '(.md$)' 9 | then 10 | echo "Only docs were updated, not running the CI: commit_range=${TRAVIS_COMMIT_RANGE}" 11 | exit 12 | fi 13 | -------------------------------------------------------------------------------- /exonum-java-binding/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -XX:TieredStopAtLevel=1 -XX:+UseParallelGC -------------------------------------------------------------------------------- /exonum-java-binding/README.md: -------------------------------------------------------------------------------- 1 | # Exonum Java Binding 2 | 3 | [![Maven Central](https://img.shields.io/maven-central/v/com.exonum.binding/exonum-java-binding-core.svg)](https://mvnrepository.com/artifact/com.exonum.binding/exonum-java-binding-core/latest) 4 | 5 | Exonum Java Binding is a framework for building blockchain applications in Java, 6 | powered by Exonum. 7 | 8 | With Exonum Java Binding you can define stateful Exonum Services in Java, 9 | configure a network of nodes and run your services in it. 10 | 11 | For more information see the relevant documentation on the tool: 12 | - [User Guide](https://exonum.com/doc/version/1.0.0/get-started/java-binding/) 13 | - [Javadocs](https://exonum.com/doc/api/java-binding/0.10.0/index.html) 14 | - [Java Service Development Tutorial](https://exonum.com/doc/version/1.0.0/get-started/first-java-service/) 15 | - [Cryptocurrency Example Service](cryptocurrency-demo) 16 | 17 | ## License 18 | This project is licensed under the Apache License, Version 2.0. 19 | See [LICENSE](../LICENSE) for details. 20 | -------------------------------------------------------------------------------- /exonum-java-binding/benchmarks/README.md: -------------------------------------------------------------------------------- 1 | # Exonum Java Benchmarks 2 | 3 | This module contains benchmarks of various Exonum Java components. 4 | 5 | It is configured to use [Java Microbenchmark Harness][jmh-home] (JMH). 6 | 7 | [jmh-home]: https://openjdk.java.net/projects/code-tools/jmh/ 8 | 9 | *This module is included in the project for easier prototyping and experimentation. 10 | It does* not *contain system-level benchmarks of Exonum services, which currently 11 | reside in an internal project:* 12 | [exonum/exonum-benchmarking](https://github.com/exonum/exonum-benchmarking) 13 | 14 | Earlier internal micro-benchmarks are 15 | in [exonum/exonum-java-benchmarks](https://github.com/exonum/exonum-java-benchmarks) 16 | project. 17 | 18 | ## Usage 19 | 20 | Build the `benchmarks.jar` (from [exonum-java-binding](..) directory): 21 | 22 | ``` 23 | # Build the benchmarks and the modules it depends upon 24 | mvn package -pl benchmarks -am 25 | ``` 26 | 27 | Get some help: 28 | 29 | ``` 30 | java -jar benchmarks/target/benchmarks.jar -h 31 | ``` 32 | -------------------------------------------------------------------------------- /exonum-java-binding/common/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/blockchain/ExecutionStatuses.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.blockchain; 18 | 19 | import com.exonum.messages.core.runtime.Errors.ExecutionStatus; 20 | import com.google.protobuf.Empty; 21 | 22 | /** 23 | * Provides pre-defined execution statuses. 24 | * 25 | * @see ExecutionStatus 26 | */ 27 | public final class ExecutionStatuses { 28 | 29 | /** 30 | * A successful execution status. 31 | */ 32 | public static final ExecutionStatus SUCCESS = ExecutionStatus.newBuilder() 33 | .setOk(Empty.getDefaultInstance()) 34 | .build(); 35 | 36 | private ExecutionStatuses() {} 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/proofs/DbKeyFunnel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.proofs; 18 | 19 | import com.exonum.binding.common.hash.Funnel; 20 | import com.exonum.binding.common.hash.PrimitiveSink; 21 | import com.exonum.binding.common.proofs.map.DbKey; 22 | 23 | /** 24 | * A funnel for a database key. Puts the raw database key (34 bytes) into the sink. 25 | */ 26 | public enum DbKeyFunnel implements Funnel { 27 | INSTANCE; 28 | 29 | @Override 30 | public void funnel(DbKey from, PrimitiveSink into) { 31 | into.putBytes(from.getRawDbKey()); 32 | } 33 | 34 | public static Funnel dbKeyFunnel() { 35 | return INSTANCE; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/proofs/ProofHashes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.proofs; 18 | 19 | import com.exonum.binding.common.hash.HashCode; 20 | import com.exonum.binding.common.hash.Hashing; 21 | 22 | public final class ProofHashes { 23 | 24 | /** 25 | * Checks that the given hash is a SHA-256 hash. 26 | * @throws IllegalArgumentException if the hash size is not equal to 256 bits 27 | */ 28 | public static void checkSha256Hash(HashCode hash) { 29 | int size = hash.bits(); 30 | if (size != Hashing.DEFAULT_HASH_SIZE_BITS) { 31 | String message = String.format("Invalid hash size (%s), must be 256 bits", size); 32 | throw new InvalidProofException(message); 33 | } 34 | } 35 | 36 | private ProofHashes() {} 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/proofs/ProofStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.proofs; 18 | 19 | /** 20 | * A status of collection proof verification. 21 | */ 22 | public interface ProofStatus { 23 | 24 | /** 25 | * Returns the description of the proof verification result. 26 | */ 27 | String getDescription(); 28 | } 29 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/proofs/list/ListProofElementEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.proofs.list; 18 | 19 | import com.google.auto.value.AutoValue; 20 | 21 | /** 22 | * A value stored in the Merkle tree at its bottom level (at height 0). 23 | */ 24 | @AutoValue 25 | abstract class ListProofElementEntry implements ListProofEntry { 26 | 27 | /** 28 | * Returns a value of the element stored at this index in the list. 29 | */ 30 | abstract byte[] getElement(); 31 | 32 | static ListProofElementEntry newInstance(long index, byte[] element) { 33 | ListProofEntry.checkIndex(index); 34 | return new AutoValue_ListProofElementEntry(index, element); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/runtime/RuntimeId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.runtime; 18 | 19 | /** 20 | * Represents well-known runtime ids, as assigned by the Exonum core. 21 | */ 22 | public enum RuntimeId { 23 | RUST(0), 24 | JAVA(1); 25 | 26 | private final int id; 27 | 28 | RuntimeId(int id) { 29 | this.id = id; 30 | } 31 | 32 | /** 33 | * Returns the numeric id assigned to this runtime by the Exonum core. 34 | */ 35 | public int getId() { 36 | return id; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/DoubleSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import static com.exonum.binding.common.serialization.SerializationUtils.checkLength; 21 | 22 | import java.nio.ByteBuffer; 23 | import java.nio.ByteOrder; 24 | 25 | enum DoubleSerializer implements Serializer { 26 | INSTANCE; 27 | 28 | @Override 29 | public byte[] toBytes(Double value) { 30 | return ByteBuffer.allocate(Double.BYTES) 31 | .order(ByteOrder.LITTLE_ENDIAN) 32 | .putDouble(value) 33 | .array(); 34 | } 35 | 36 | @Override 37 | public Double fromBytes(byte[] serializedValue) { 38 | checkLength(serializedValue, Double.BYTES); 39 | 40 | return ByteBuffer.wrap(serializedValue) 41 | .order(ByteOrder.LITTLE_ENDIAN) 42 | .getDouble(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/Fixed32Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import static com.exonum.binding.common.serialization.SerializationUtils.checkLength; 21 | 22 | import java.nio.ByteBuffer; 23 | import java.nio.ByteOrder; 24 | 25 | enum Fixed32Serializer implements Serializer { 26 | INSTANCE; 27 | 28 | @Override 29 | public byte[] toBytes(Integer value) { 30 | return ByteBuffer.allocate(Integer.BYTES) 31 | .order(ByteOrder.LITTLE_ENDIAN) 32 | .putInt(value) 33 | .array(); 34 | } 35 | 36 | @Override 37 | public Integer fromBytes(byte[] serializedValue) { 38 | checkLength(serializedValue, Integer.BYTES); 39 | 40 | return ByteBuffer.wrap(serializedValue) 41 | .order(ByteOrder.LITTLE_ENDIAN) 42 | .getInt(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/Fixed64Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import static com.exonum.binding.common.serialization.SerializationUtils.checkLength; 21 | 22 | import java.nio.ByteBuffer; 23 | import java.nio.ByteOrder; 24 | 25 | enum Fixed64Serializer implements Serializer { 26 | INSTANCE; 27 | 28 | @Override 29 | public byte[] toBytes(Long value) { 30 | ByteBuffer buf = ByteBuffer.allocate(Long.BYTES) 31 | .order(ByteOrder.LITTLE_ENDIAN); 32 | buf.putLong(value); 33 | return buf.array(); 34 | } 35 | 36 | @Override 37 | public Long fromBytes(byte[] serializedValue) { 38 | checkLength(serializedValue, Long.BYTES); 39 | 40 | return ByteBuffer.wrap(serializedValue) 41 | .order(ByteOrder.LITTLE_ENDIAN) 42 | .getLong(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/FloatSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import static com.exonum.binding.common.serialization.SerializationUtils.checkLength; 21 | 22 | import java.nio.ByteBuffer; 23 | import java.nio.ByteOrder; 24 | 25 | enum FloatSerializer implements Serializer { 26 | INSTANCE; 27 | 28 | @Override 29 | public byte[] toBytes(Float value) { 30 | return ByteBuffer.allocate(Float.BYTES) 31 | .order(ByteOrder.LITTLE_ENDIAN) 32 | .putFloat(value) 33 | .array(); 34 | } 35 | 36 | @Override 37 | public Float fromBytes(byte[] serializedValue) { 38 | checkLength(serializedValue, Float.BYTES); 39 | 40 | return ByteBuffer.wrap(serializedValue) 41 | .order(ByteOrder.LITTLE_ENDIAN) 42 | .getFloat(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/HashCodeSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import com.exonum.binding.common.hash.HashCode; 21 | 22 | enum HashCodeSerializer implements Serializer { 23 | INSTANCE; 24 | 25 | @Override 26 | public byte[] toBytes(HashCode value) { 27 | return value.asBytes(); 28 | } 29 | 30 | @Override 31 | public HashCode fromBytes(byte[] serializedValue) { 32 | return HashCode.fromBytes(serializedValue); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/NoOpSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | enum NoOpSerializer implements Serializer { 21 | INSTANCE; 22 | 23 | @Override 24 | public byte[] toBytes(byte[] value) { 25 | return value; 26 | } 27 | 28 | @Override 29 | public byte[] fromBytes(byte[] serializedValue) { 30 | return serializedValue; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/PrivateKeySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import com.exonum.binding.common.crypto.PrivateKey; 21 | 22 | enum PrivateKeySerializer implements Serializer { 23 | INSTANCE; 24 | 25 | @Override 26 | public byte[] toBytes(PrivateKey value) { 27 | return value.toBytes(); 28 | } 29 | 30 | @Override 31 | public PrivateKey fromBytes(byte[] serializedValue) { 32 | return PrivateKey.fromBytes(serializedValue); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/PublicKeySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import com.exonum.binding.common.crypto.PublicKey; 21 | 22 | enum PublicKeySerializer implements Serializer { 23 | INSTANCE; 24 | 25 | @Override 26 | public byte[] toBytes(PublicKey value) { 27 | return value.toBytes(); 28 | } 29 | 30 | @Override 31 | public PublicKey fromBytes(byte[] serializedValue) { 32 | return PublicKey.fromBytes(serializedValue); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/SerializationUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import static com.google.common.base.Preconditions.checkArgument; 21 | 22 | final class SerializationUtils { 23 | 24 | /** 25 | * Performs check that bytes array has correct length. 26 | * 27 | * @param array bytes array 28 | * @param length expected length 29 | * @throws IllegalArgumentException thrown if length is incorrect 30 | */ 31 | static void checkLength(byte[] array, int length) { 32 | checkArgument(array.length == length, 33 | "Expected an array of size %s, but was %s", length, array.length); 34 | } 35 | 36 | private SerializationUtils() { 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/java/com/exonum/binding/common/serialization/TransactionMessageSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.serialization; 18 | 19 | import com.exonum.binding.common.message.TransactionMessage; 20 | 21 | enum TransactionMessageSerializer implements Serializer { 22 | INSTANCE; 23 | 24 | @Override 25 | public byte[] toBytes(TransactionMessage value) { 26 | return value.toBytes(); 27 | } 28 | 29 | @Override 30 | public TransactionMessage fromBytes(byte[] serializedValue) { 31 | return TransactionMessage.fromBytes(serializedValue); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/proto/exonum/java/deploy_arguments.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | syntax = "proto3"; 18 | 19 | package exonum.java; 20 | 21 | option java_package = "com.exonum.binding.common.messages"; 22 | option java_multiple_files = true; 23 | 24 | 25 | /* Java ServiceRuntime deploy arguments, specified in the deploy request 26 | * transaction. Currently only a single protocol is supported: 27 | * loading an artifact from a file. */ 28 | message DeployArguments { 29 | 30 | /* A name of the service artifact file located in the directory 31 | * for storing Java service artifacts. */ 32 | string artifact_filename = 1; 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/main/proto/exonum/java/service.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package exonum.java; 18 | 19 | option java_package = "com.exonum.binding.common.messages"; 20 | 21 | // Service configuration arguments in a text-based format. 22 | // The configuration string must be in one of the pre-defined formats. 23 | message ServiceConfiguration { 24 | enum Format { 25 | TEXT = 0; 26 | // Identifies that the given configuration represented as Json. 27 | JSON = 1; 28 | // Identifies that the given configuration represented as Properties, 29 | // i.e. `key=value` pairs. 30 | // See the format specification in java.util.Properties: 31 | // https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Properties.html#load(java.io.Reader) 32 | PROPERTIES = 2; 33 | } 34 | Format format = 1; 35 | string value = 2; 36 | } 37 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/test/java/com/exonum/binding/common/blockchain/ExecutionStatusesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.blockchain; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertTrue; 20 | 21 | import com.exonum.messages.core.runtime.Errors.ExecutionStatus; 22 | import org.junit.jupiter.api.Test; 23 | 24 | class ExecutionStatusesTest { 25 | 26 | @Test 27 | void success() { 28 | ExecutionStatus s = ExecutionStatuses.SUCCESS; 29 | assertTrue(s.hasOk()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/test/java/com/exonum/binding/common/crypto/AbstractKeyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.crypto; 18 | 19 | import nl.jqno.equalsverifier.EqualsVerifier; 20 | import org.junit.jupiter.api.Test; 21 | 22 | class AbstractKeyTest { 23 | 24 | @Test 25 | void verifyEqualsPublicKey() { 26 | EqualsVerifier.forClass(PublicKey.class) 27 | .usingGetClass() 28 | .verify(); 29 | } 30 | 31 | @Test 32 | void verifyEqualsPrivateKey() { 33 | EqualsVerifier.forClass(PrivateKey.class) 34 | .usingGetClass() 35 | .verify(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/test/java/com/exonum/binding/common/crypto/Ed25519CryptoFunctionWithBundledTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.crypto; 18 | 19 | import com.exonum.binding.test.CiOnly; 20 | import com.goterl.lazycode.lazysodium.utils.LibraryLoader.Mode; 21 | import org.junit.jupiter.api.DisplayName; 22 | 23 | @Forked 24 | @CiOnly 25 | @DisplayName("Test that the Ed25519 crypto function works with the libsodium, " 26 | + "bundled in lazysodium") 27 | class Ed25519CryptoFunctionWithBundledTest extends Ed25519CryptoFunctionTestable { 28 | 29 | @Override 30 | Ed25519CryptoFunction createFunction() { 31 | return new Ed25519CryptoFunction(Mode.BUNDLED_ONLY); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/test/java/com/exonum/binding/common/crypto/Ed25519CryptoFunctionWithSystemSodiumTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.crypto; 18 | 19 | import com.goterl.lazycode.lazysodium.utils.LibraryLoader.Mode; 20 | import org.junit.jupiter.api.DisplayName; 21 | 22 | @Forked 23 | @DisplayName("Test that the Ed25519 crypto function works with the installed libsodium") 24 | class Ed25519CryptoFunctionWithSystemSodiumTest extends Ed25519CryptoFunctionTestable { 25 | 26 | @Override 27 | Ed25519CryptoFunction createFunction() { 28 | return new Ed25519CryptoFunction(Mode.SYSTEM_ONLY); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/test/java/com/exonum/binding/common/crypto/Forked.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.crypto; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.Tag; 25 | 26 | 27 | /** 28 | * Indicates that a test class must be run in a forked individual VM. 29 | * 30 | *

For this annotation to have any effect, the surefire and failsafe plugin must be configured 31 | * accordingly. 32 | */ 33 | @Target({ElementType.TYPE}) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Inherited 36 | @Tag("forked") 37 | public @interface Forked { 38 | 39 | } 40 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/test/java/com/exonum/binding/common/runtime/JavaArtifactUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.common.runtime; 18 | 19 | import static com.exonum.binding.common.runtime.JavaArtifactUtils.checkNoForbiddenChars; 20 | import static org.junit.jupiter.api.Assertions.assertThrows; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | class JavaArtifactUtilsTest { 25 | 26 | @Test 27 | void checkArtifactWithNoForbiddenCharacters() { 28 | String name = "com.acme/foo:1.0"; 29 | checkNoForbiddenChars(name); 30 | } 31 | 32 | @Test 33 | void checkArtifactWithForbiddenCharacters() { 34 | String name = "com.acme foo:1.0"; 35 | assertThrows(IllegalArgumentException.class, () -> checkNoForbiddenChars(name)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/test/java/com/exonum/binding/common/serialization/BoolSerializerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.common.serialization; 19 | 20 | import static com.exonum.binding.common.serialization.StandardSerializersTestUtils.invalidBytesValueTest; 21 | import static com.exonum.binding.common.serialization.StandardSerializersTestUtils.roundTripTest; 22 | 23 | import org.junit.jupiter.api.Test; 24 | 25 | class BoolSerializerTest { 26 | 27 | private final Serializer serializer = BoolSerializer.INSTANCE; 28 | 29 | @Test 30 | void roundTrip() { 31 | 32 | roundTripTest(true, serializer); 33 | roundTripTest(false, serializer); 34 | } 35 | 36 | @Test 37 | void deserializeInvalidValue() { 38 | byte[] invalidValue = {2}; 39 | invalidBytesValueTest(invalidValue, serializer); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /exonum-java-binding/common/src/test/proto/TestMessage.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.exonum.binding.common.serialization"; 4 | option java_outer_classname = "TestProtos"; 5 | 6 | message Point { 7 | sint32 x = 1; 8 | sint32 y = 2; 9 | } 10 | 11 | message Targets { 12 | // Target points by their names. 13 | map targets = 1; 14 | } 15 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "java_bindings" 3 | version = "0.11.0-SNAPSHOT" 4 | authors = ["Exonum Team "] 5 | edition = "2018" 6 | 7 | [workspace] 8 | members = ["integration_tests", "exonum-java"] 9 | 10 | [lib] 11 | crate-type = ["dylib"] 12 | 13 | [features] 14 | # Enables native handles checking. Useful for debugging. 15 | resource-manager = [] 16 | 17 | [dependencies] 18 | anyhow = "1.0" 19 | chrono = "0.4" 20 | exonum = { version = "1.0.0", features = ["rocksdb_snappy", "rocksdb_lz4", "rocksdb_zlib", "rocksdb_bzip2"] } 21 | exonum-btc-anchoring = "1.0.0" 22 | exonum-cli = "1.0.0" 23 | exonum-derive = "1.0.0" 24 | exonum-proto = "1.0.0" 25 | exonum-rust-runtime = "1.0.0" 26 | exonum-supervisor = "1.0.0" 27 | exonum-testkit = "1.0.0" 28 | exonum-time = "1.0.0" 29 | futures = "0.1" 30 | jni = { version = "0.15", features = ["invocation"] } 31 | lazy_static = "1.3" 32 | log = "0.4" 33 | parking_lot = "0.10" 34 | protobuf = { version = "2.8", features = ["with-serde"] } 35 | serde = { version = "1.0", features = ["serde_derive"] } 36 | structopt = "0.3" 37 | 38 | [build-dependencies] 39 | exonum-build = { version = "1.0.1" } 40 | 41 | [profile.dev] 42 | rpath = true 43 | 44 | [profile.release] 45 | rpath = true 46 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/exonum-java/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "exonum-java" 3 | version = "0.11.0-SNAPSHOT" 4 | authors = ["Exonum team "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | anyhow = "1.0" 9 | env_logger = "0.6" 10 | exonum-explorer-service = "1.0.0" 11 | exonum-node = "1.0.0" 12 | exonum-system-api = "1.0.0" 13 | # Specify the "resource-manager" feature explicitly to prevent issues with linking (see ECR-2855). 14 | # Although its primary goal is to detect _programming_ errors that shall not occur 15 | # in a correct application early, it is currently required in the application 16 | # because some public APIs in Java permit passing arbitrary pointers (e.g., Snapshot#newInstance). 17 | java_bindings = { path = "..", features = ["resource-manager"] } 18 | log = "0.4" 19 | serde = { version = "1.0", features = ["serde_derive"] } 20 | tokio = "0.2.13" 21 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/exonum-java/README.md: -------------------------------------------------------------------------------- 1 | # Exonum Java Binding Application 2 | 3 | Exonum Java Binding is a framework for building blockchain applications in Java, 4 | powered by Exonum. 5 | 6 | With Exonum Java Binding you can define stateful Exonum Services in Java, 7 | configure a network of nodes and run your services in it. 8 | 9 | For more information see the relevant documentation on the tool: 10 | - [User Guide](https://exonum.com/doc/version/1.0.0/get-started/java-binding/) 11 | - [Javadocs](https://exonum.com/doc/api/java-binding/0.10.0/index.html) 12 | 13 | # License 14 | 15 | This project is licensed under the Apache License, Version 2.0. 16 | See [LICENSE](LICENSE) for details. 17 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/exonum-java/log4j-fallback.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/exonum-java/qa-service.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 3000 5 | private-api-port: 3010 6 | 7 | deadline_height: 20000 8 | 9 | runtimes: 10 | java: 1 11 | 12 | plugins: 13 | runtime: 14 | java: "exonum_java_runtime_plugin.JavaDeploySpecLoader" 15 | artifact: 16 | qa-service: "exonum_instance_configuration_plugin.InstanceSpecLoader" 17 | 18 | artifacts: 19 | qa-service: 20 | runtime: java 21 | name: "com.exonum.binding/exonum-java-binding-qa-service" 22 | version: "0.11.0-SNAPSHOT" 23 | spec: 24 | artifact_filename: "exonum-java-binding-qa-service-0.11.0-SNAPSHOT-artifact.jar" 25 | action: deploy 26 | time: 27 | runtime: rust 28 | name: "exonum-time" 29 | version: "1.0.0" 30 | 31 | instances: 32 | qa-service: 33 | artifact: qa-service 34 | config: 35 | sources: "../../../qa-service/src/main/proto" 36 | config_message_source: "config.proto" 37 | message_name: "QaConfiguration" 38 | data: 39 | time_oracle_name: "time" 40 | action: start 41 | time: 42 | artifact: time 43 | action: start 44 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/generate_licenses.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Gather licenses for every Rust dependency and print it in the file in a readable form. 3 | # Resulting file destination is either specified by `PACKAGING_ETC_DIR` variable, or 4 | # is the script directory (exonum-java-binding/core/rust) 5 | 6 | # Fail immediately in case of errors and/or unset variables 7 | set -eu -o pipefail 8 | 9 | cargo-license -h &> /dev/null || cargo install cargo-license 10 | 11 | # Going to exonum-java-binding/core/rust directory. 12 | backup_dir=${PWD} 13 | script_dir="$(dirname "$(realpath -s "$0")")" # Directory of this script. Must be exonum-java-binding/core/rust 14 | cd "${script_dir}" 15 | 16 | cargo-license --json > "${PACKAGING_ETC_DIR:-.}/LICENSES-THIRD-PARTY-NATIVE" 17 | 18 | # Restoring initial directory. 19 | cd "${backup_dir}" 20 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/integration_tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "integration_tests" 3 | version = "0.11.0-SNAPSHOT" 4 | authors = ["Exonum Team "] 5 | edition = "2018" 6 | publish = false 7 | workspace = ".." 8 | 9 | [lib] 10 | crate-type = ["dylib"] 11 | 12 | [dependencies] 13 | exonum-testkit = "1.0.0" 14 | exonum-derive = "1.0.0" 15 | futures = "0.3" 16 | # Specify the "resource-manager" feature explicitly to prevent issues with linking (see ECR-2855) 17 | java_bindings = { path = "..", features = ["resource-manager"] } 18 | lazy_static = "1.3" 19 | rand = "0.7" 20 | serde = { version = "1.0", features = ["serde_derive"] } 21 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/integration_tests/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/integration_tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | pub mod example_proxy; 16 | pub mod vm; 17 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/integration_tests/tests/jni_cache_not_initialized.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | use java_bindings::utils::{assert_panics, jni_cache}; 16 | 17 | #[test] 18 | fn cache_not_initialized() { 19 | assert_panics("JNI cache is not initialized", || { 20 | jni_cache::runtime_adapter::execute_tx_id() 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/src/handle/resource_manager/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //! The main goal of resource manager is early detection of possible problems with resources 16 | //! management and accessing objects with pointers. Not required in production. 17 | 18 | #[cfg(not(feature = "resource-manager"))] 19 | #[path = "stub.rs"] 20 | mod imp; 21 | 22 | #[cfg(feature = "resource-manager")] 23 | #[path = "imp.rs"] 24 | mod imp; 25 | 26 | pub use self::imp::*; 27 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/src/handle/resource_manager/stub.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //! See actual implementation (`imp.rs`) for the documentation. 16 | 17 | #![allow(missing_docs)] 18 | 19 | use super::super::Handle; 20 | 21 | pub fn add_handle(_: Handle) {} 22 | pub fn remove_handle(_: Handle) {} 23 | pub fn check_handle(_: Handle) {} 24 | pub fn known_handles() -> usize { 25 | 0 26 | } 27 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/src/proto/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //! Module of the rust-protobuf generated files. 16 | 17 | #![allow(bare_trait_objects)] 18 | #![allow(renamed_and_removed_lints)] 19 | 20 | pub use self::testkit::*; 21 | pub use exonum::proto::schema::*; 22 | 23 | include!(concat!(env!("OUT_DIR"), "/protobuf_mod.rs")); 24 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/src/proxy/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | mod node; 16 | mod runtime; 17 | 18 | pub use self::node::*; 19 | pub use self::runtime::*; 20 | -------------------------------------------------------------------------------- /exonum-java-binding/core/rust/src/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | mod config; 18 | mod error; 19 | mod java_runtime_factory; 20 | mod library_loader; 21 | mod paths; 22 | 23 | pub use self::config::*; 24 | pub use self::error::*; 25 | pub use self::java_runtime_factory::*; 26 | pub use self::library_loader::get_lib_version; 27 | pub use self::paths::*; 28 | -------------------------------------------------------------------------------- /exonum-java-binding/core/spotbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/annotations/AutoGenerationCandidate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation intended to mark APIs that are good candidates to be generated auto-magically. 26 | */ 27 | @Retention(RetentionPolicy.SOURCE) 28 | @Target({ 29 | ElementType.ANNOTATION_TYPE, 30 | ElementType.TYPE, 31 | ElementType.METHOD 32 | }) 33 | public @interface AutoGenerationCandidate { 34 | /** 35 | * Why or how an element can be auto-generated. 36 | */ 37 | String reason() default ""; 38 | } 39 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/proxy/CancellableCleanAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.proxy; 18 | 19 | /** 20 | * A cancellable clean action can be cancelled. That is useful, for instance, when 21 | * a Java native proxy transfers ownership over the native peer back to the native code. 22 | */ 23 | public interface CancellableCleanAction 24 | extends CleanAction { 25 | 26 | /** 27 | * Cancels this clean action, making {@link #clean()} a no-op. This operation cannot be reversed. 28 | */ 29 | void cancel(); 30 | } 31 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/proxy/CloseFailuresException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.proxy; 18 | 19 | /** 20 | * Indicates that there were failures when it was attempted to close some native proxies. 21 | * 22 | * @see Cleaner#close() 23 | */ 24 | public final class CloseFailuresException extends Exception { 25 | 26 | private static final long serialVersionUID = 5578500940650637495L; 27 | 28 | /** 29 | * Constructs a new exception with the specified detail message. The 30 | * cause is not initialized, and may subsequently be initialized by 31 | * a call to {@link #initCause}. 32 | * 33 | * @param message the detail message. The detail message is saved for 34 | * later retrieval by the {@link #getMessage()} method. 35 | */ 36 | CloseFailuresException(String message) { 37 | super(message); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/runtime/BlockchainDataFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import com.exonum.binding.core.blockchain.BlockchainData; 20 | import com.exonum.binding.core.storage.database.AbstractAccess; 21 | 22 | /** 23 | * A factory of {@link BlockchainData}. 24 | * 25 | *

Enables easier unit testing of the {@link ServiceRuntime} and {@link ServiceNodeProxy}. 26 | */ 27 | interface BlockchainDataFactory { 28 | 29 | /** 30 | * Creates a BlockchainData for the service with the given name. 31 | * 32 | * @see BlockchainData#fromRawAccess(AbstractAccess, String) 33 | */ 34 | default BlockchainData fromRawAccess(AbstractAccess rawAccess, String serviceName) { 35 | return BlockchainData.fromRawAccess(rawAccess, serviceName); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/runtime/ServiceLoadingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | /** 20 | * Indicates that a service runtime failed to load the service artifact. 21 | */ 22 | public class ServiceLoadingException extends Exception { 23 | 24 | private static final long serialVersionUID = -5073976663800635538L; 25 | 26 | public ServiceLoadingException(String message) { 27 | super(message); 28 | } 29 | 30 | public ServiceLoadingException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/service/AbstractServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.service; 18 | 19 | import com.google.inject.AbstractModule; 20 | 21 | /** 22 | * A base class for {@link ServiceModule} implementations provided for convenience. 23 | * 24 | *

The implementation must be specified as an {@linkplain org.pf4j.Extension extension}: 25 | *

26 |  *   @Extension
27 |  *   class MyServiceModule extends AbstractServiceModule {
28 |  *
29 |  *   }
30 |  * 
31 | */ 32 | public abstract class AbstractServiceModule extends AbstractModule implements ServiceModule { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/service/TransactionSubmissionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.service; 18 | 19 | import com.exonum.binding.core.transaction.RawTransaction; 20 | 21 | /** 22 | * Indicates that a transaction could not be 23 | * {@linkplain Node#submitTransaction(RawTransaction) submitted}. 24 | * For example, the submitted transaction is not valid — belongs to an unknown service. 25 | */ 26 | public final class TransactionSubmissionException extends RuntimeException { 27 | 28 | private static final long serialVersionUID = -4818447239123659240L; 29 | 30 | public TransactionSubmissionException(String message) { 31 | super(message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/service/adapters/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * An internal package with adapters of Java Service interfaces 19 | * to the interface, convenient to the native code. That brings such benefits: 20 | *
    21 | *
  • Separates user-facing interface and the framework implementation, 22 | * enabling us to change them independently. 23 | *
  • Provides the native code with a convenient interface (simpler, faster, more reliable). 24 | *
25 | * 26 | *

Also contains an utility factory to produce proxies of native accesses. 27 | */ 28 | package com.exonum.binding.core.service.adapters; 29 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/storage/indices/ImmutableModificationCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | enum ImmutableModificationCounter implements ModificationCounter { 20 | 21 | INSTANCE; 22 | 23 | private static final int INITIAL_VALUE = 0; 24 | 25 | @Override 26 | public boolean isModifiedSince(int lastValue) { 27 | return false; 28 | } 29 | 30 | @Override 31 | public int getCurrentValue() { 32 | return INITIAL_VALUE; 33 | } 34 | 35 | @Override 36 | public void notifyModified() { 37 | throw new IllegalStateException("Immutable counter cannot be modified"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/storage/indices/IncrementalModificationCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | final class IncrementalModificationCounter implements ModificationCounter { 20 | 21 | private int counter = 0; 22 | 23 | @Override 24 | public boolean isModifiedSince(int lastValue) { 25 | return counter != lastValue; 26 | } 27 | 28 | @Override 29 | public int getCurrentValue() { 30 | return counter; 31 | } 32 | 33 | @Override 34 | public void notifyModified() { 35 | counter++; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/storage/indices/RustIter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | import java.util.Optional; 20 | 21 | /** 22 | * An interface corresponding to 23 | * std::iter::Iterator 24 | * from the Rust standard library. 25 | * 26 | * @param type of elements returned by this iterator 27 | */ 28 | interface RustIter { 29 | 30 | /** 31 | * Advance the iterator to the next item. 32 | * 33 | * @return the next item or {@link Optional#empty} if the end is reached. 34 | */ 35 | Optional next(); 36 | } 37 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/java/com/exonum/binding/core/util/OsInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.util; 18 | 19 | class OsInfo { 20 | 21 | private static final boolean onWindows; 22 | 23 | static { 24 | String osName = System.getProperty("os.name").toLowerCase(); 25 | onWindows = osName.contains("windows"); 26 | } 27 | 28 | /** 29 | * Returns true if the OS is Windows. 30 | */ 31 | static boolean isWindows() { 32 | return onWindows; 33 | } 34 | 35 | private OsInfo() {} 36 | } 37 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/main/proto/exonum/testkit/testkit.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package exonum.testkit; 18 | 19 | option java_package = "com.exonum.binding.core.testkit.internal"; 20 | option java_outer_classname = "TestKitProtos"; 21 | 22 | import "exonum/runtime/lifecycle.proto"; 23 | import "exonum/runtime/base.proto"; 24 | 25 | // DTO for TestKit initialization. 26 | message TestKitServiceInstances { 27 | repeated TestKitService services = 1; 28 | } 29 | 30 | message TestKitService { 31 | // Artifact description. 32 | exonum.runtime.ArtifactSpec artifact_spec = 1; 33 | // Services to start on blockchain instantiation. 34 | repeated exonum.runtime.InstanceInitParams service_specs = 2; 35 | } 36 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/runtime/EvilPluginFailingToStart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import org.pf4j.Plugin; 20 | import org.pf4j.PluginRuntimeException; 21 | import org.pf4j.PluginWrapper; 22 | 23 | public class EvilPluginFailingToStart extends Plugin { 24 | 25 | public EvilPluginFailingToStart(PluginWrapper wrapper) { 26 | super(wrapper); 27 | } 28 | 29 | @Override 30 | public void start() { 31 | throw new PluginRuntimeException("I am an evil plugin so I won't start"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/runtime/Pf4jServiceLoaderWithDefaultIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import com.exonum.binding.test.CiOnly; 20 | import org.pf4j.DefaultPluginManager; 21 | import org.pf4j.PluginManager; 22 | 23 | /** 24 | * Verifies that {@link Pf4jServiceLoader} works correctly with the {@link DefaultPluginManager} 25 | * so that we are able to understand if our {@linkplain JarPluginManager custom plugin manager} 26 | * has any impact in case of any problems. 27 | */ 28 | @CiOnly // We don't use DefaultPluginManager in prod, hence run this on CI-server only 29 | class Pf4jServiceLoaderWithDefaultIntegrationTest extends Pf4jServiceLoaderIntegrationTestable { 30 | 31 | @Override 32 | PluginManager createPluginManager() { 33 | return new DefaultPluginManager(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/runtime/Pf4jServiceLoaderWithJarIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import org.pf4j.PluginManager; 20 | 21 | /** 22 | * Verifies that {@link Pf4jServiceLoader} works correctly with the {@link JarPluginManager}, 23 | * our default implementation. 24 | */ 25 | class Pf4jServiceLoaderWithJarIntegrationTest extends Pf4jServiceLoaderIntegrationTestable { 26 | 27 | @Override 28 | PluginManager createPluginManager() { 29 | return new JarPluginManager(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/runtime/TestService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import com.exonum.binding.core.service.Node; 20 | import com.exonum.binding.core.service.Service; 21 | import io.vertx.ext.web.Router; 22 | 23 | class TestService implements Service { 24 | @Override 25 | public void createPublicApiHandlers(Node node, Router router) { 26 | // no-op 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/runtime/TestServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | 22 | public class TestServiceModule extends AbstractServiceModule { 23 | 24 | @Override 25 | protected void configure() { 26 | bind(Service.class) 27 | .to(TestService.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/runtime/TestServiceModule1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | 21 | @SuppressWarnings("WeakerAccess") 22 | public class TestServiceModule1 extends AbstractServiceModule { 23 | } 24 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/runtime/TestServiceModule2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | 21 | @SuppressWarnings("WeakerAccess") 22 | public final class TestServiceModule2 extends AbstractServiceModule { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/runtime/TestServiceModuleInaccessibleCtor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.runtime; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | 21 | final class TestServiceModuleInaccessibleCtor extends AbstractServiceModule { 22 | 23 | private TestServiceModuleInaccessibleCtor() { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/database/ForkTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.database; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertTrue; 20 | 21 | import com.exonum.binding.core.proxy.Cleaner; 22 | import org.junit.jupiter.api.Test; 23 | 24 | class ForkTest { 25 | 26 | @Test 27 | void canModify() { 28 | Fork fork = Fork.newInstance(0x0A, false, new Cleaner()); 29 | assertTrue(fork.canModify()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/database/SnapshotTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.database; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertFalse; 20 | 21 | import com.exonum.binding.core.proxy.Cleaner; 22 | import org.junit.jupiter.api.Test; 23 | 24 | class SnapshotTest { 25 | 26 | @Test 27 | void cannotModify() { 28 | Snapshot s = Snapshot.newInstance(0x0A, false, new Cleaner()); 29 | assertFalse(s.canModify()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/indices/EntryIndexProxyIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | import static com.exonum.binding.common.serialization.StandardSerializers.string; 20 | 21 | import com.exonum.binding.core.storage.database.Access; 22 | 23 | class EntryIndexProxyIntegrationTest 24 | extends BaseEntryIndexProxyIntegrationTest> { 25 | 26 | @Override 27 | EntryIndex create(IndexAddress address, Access access) { 28 | return access.getEntry(address, string()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/indices/ImmutableModificationCounterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertThrows; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | class ImmutableModificationCounterTest { 24 | 25 | private static final ImmutableModificationCounter COUNTER = ImmutableModificationCounter.INSTANCE; 26 | 27 | @Test 28 | void forbidsModifications() { 29 | assertThrows(IllegalStateException.class, COUNTER::notifyModified); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/indices/IndexAddressTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | import nl.jqno.equalsverifier.EqualsVerifier; 20 | import org.junit.jupiter.api.Test; 21 | 22 | class IndexAddressTest { 23 | 24 | @Test 25 | void verifyEquals() { 26 | EqualsVerifier.forClass(IndexAddress.class) 27 | .withNonnullFields("name") 28 | .verify(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/indices/IndexConstructorOne.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | import com.exonum.binding.common.serialization.Serializer; 20 | import com.exonum.binding.core.storage.database.Access; 21 | 22 | @FunctionalInterface 23 | interface IndexConstructorOne { 24 | IndexT create(IndexAddress address, Access access, Serializer serializer); 25 | } 26 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/indices/ListIndexProxyGroupIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | import com.exonum.binding.common.serialization.StandardSerializers; 20 | import com.exonum.binding.core.storage.database.Access; 21 | 22 | class ListIndexProxyGroupIntegrationTest extends BaseListIndexProxyGroupTestable { 23 | 24 | @Override 25 | ListIndex createInGroup(byte[] id, Access access) { 26 | IndexAddress address = IndexAddress.valueOf("list_index_group_IT", id); 27 | return access.getList(address, StandardSerializers.string()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/indices/ProofListIndexProxyGroupIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | import com.exonum.binding.common.serialization.StandardSerializers; 20 | import com.exonum.binding.core.storage.database.Access; 21 | 22 | class ProofListIndexProxyGroupIntegrationTest 23 | extends BaseListIndexProxyGroupTestable { 24 | 25 | @Override 26 | ListIndex createInGroup(byte[] id, Access access) { 27 | return access.getProofList(IndexAddress.valueOf("proof_list_group_IT", id), 28 | StandardSerializers.string()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/indices/RustIterTestFake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.core.storage.indices; 18 | 19 | import java.util.Iterator; 20 | import java.util.Optional; 21 | 22 | /** 23 | * A simple RustIter fake with no native code. 24 | * 25 | *

An adapter of {@link Iterator} to {@link RustIter}. 26 | */ 27 | public class RustIterTestFake implements RustIter { 28 | private final Iterator iterator; 29 | 30 | RustIterTestFake(Iterable iterable) { 31 | this.iterator = iterable.iterator(); 32 | } 33 | 34 | @Override 35 | public Optional next() { 36 | return iterator.hasNext() ? Optional.of(iterator.next()) 37 | : Optional.empty(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/proto/TestMessages.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.exonum.binding.core.storage.indices"; 4 | option java_outer_classname = "TestProtoMessages"; 5 | 6 | message Id { 7 | string id = 1; 8 | } 9 | 10 | message Point { 11 | sint32 x = 1; 12 | sint32 y = 2; 13 | } 14 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /exonum-java-binding/core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | # Use the mock maker that enables Mockito to mock _final_ classes. 2 | mock-maker-inline 3 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/cryptocurrency-demo.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 3000 5 | private-api-port: 3010 6 | 7 | deadline_height: 10000 8 | 9 | runtimes: 10 | java: 1 11 | 12 | plugins: 13 | runtime: 14 | java: "exonum_java_runtime_plugin.JavaDeploySpecLoader" 15 | artifact: {} 16 | 17 | artifacts: 18 | cryptocurrency: 19 | runtime: java 20 | name: "com.exonum.binding/exonum-java-binding-cryptocurrency-demo" 21 | version: "0.11.0-SNAPSHOT" 22 | spec: 23 | artifact_filename: "exonum-java-binding-cryptocurrency-demo-0.11.0-SNAPSHOT-artifact.jar" 24 | action: deploy 25 | 26 | instances: 27 | cryptocurrency: 28 | artifact: cryptocurrency 29 | action: start 30 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parserOptions": { 3 | "ecmaVersion": 2017 4 | }, 5 | "extends": "plugin:vue/recommended", 6 | "rules": { 7 | "vue/max-attributes-per-line": 0, 8 | "object-curly-spacing" : [2, "always"] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | npm-debug.log* 3 | /dist/ 4 | /build/ 5 | 6 | # Generated by protobuf automatically 7 | src/proto/proto.js 8 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exonum/exonum-java-binding/d02920311e6a3142738345f457e10a4ffa19a1a8/exonum-java-binding/cryptocurrency-demo/frontend/favicon.ico -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/images/exonum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exonum/exonum-java-binding/d02920311e6a3142738345f457e10a4ffa19a1a8/exonum-java-binding/cryptocurrency-demo/frontend/images/exonum.png -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/images/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exonum/exonum-java-binding/d02920311e6a3142738345f457e10a4ffa19a1a8/exonum-java-binding/cryptocurrency-demo/frontend/images/spinner.gif -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/App.vue: -------------------------------------------------------------------------------- 1 | 31 | 32 | 42 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/app.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'babel-polyfill'; 18 | import Vue from 'vue' 19 | import router from './router' 20 | import numeral from './directives/numeral' 21 | import Validate from './plugins/validate' 22 | import Notify from './plugins/notify' 23 | import Blockchain from './plugins/blockchain' 24 | import App from './App.vue' 25 | import store from './store' 26 | 27 | Vue.use(numeral) 28 | Vue.use(Validate) 29 | Vue.use(Notify) 30 | Vue.use(Blockchain) 31 | 32 | new Vue({ 33 | el: '#app', 34 | router, 35 | store, 36 | render: createElement => createElement(App) 37 | }) 38 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/components/Navbar.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 44 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/components/Spinner.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 13 | 14 | 48 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/components/Tab.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 34 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/components/Tabs.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 44 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/directives/numeral.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import numeral from 'numeral' 18 | 19 | export default { 20 | install(Vue) { 21 | Vue.directive('numeral', { 22 | bind(el, binding) { 23 | el.innerHTML = numeral(binding.value).format('$0,0') 24 | }, 25 | update(el, binding) { 26 | el.innerHTML = numeral(binding.value).format('$0,0') 27 | } 28 | }) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/plugins/notify.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import Noty from 'noty' 18 | 19 | export default { 20 | install(Vue) { 21 | Vue.prototype.$notify = function(text, type = 'information') { 22 | new Noty({ 23 | theme: 'bootstrap-v4', 24 | timeout: 5000, 25 | type: type, 26 | text: text, 27 | killer: true, 28 | progressBar: false 29 | }).show() 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/plugins/validate.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export default { 18 | install(Vue) { 19 | Vue.prototype.$validateHex = function(hash, bytes) { 20 | bytes = bytes || 32 21 | 22 | if (typeof hash !== 'string') { 23 | return false 24 | } else if (hash.length !== bytes * 2) { 25 | // hexadecimal string is of wrong length 26 | return false 27 | } 28 | 29 | for (let i = 0; i < hash.length; i++) { 30 | if (isNaN(parseInt(hash[i], 16))) { 31 | // invalid symbol in hexadecimal string 32 | return false 33 | } 34 | } 35 | 36 | return true 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/proto/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exonum/exonum-java-binding/d02920311e6a3142738345f457e10a4ffa19a1a8/exonum-java-binding/cryptocurrency-demo/frontend/src/proto/.gitkeep -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/frontend/src/store/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import Vue from 'vue' 18 | import Vuex from 'vuex' 19 | 20 | const KEY = 'cryptocurrency' 21 | const keyPair = JSON.parse(localStorage.getItem(KEY)) 22 | 23 | Vue.use(Vuex) 24 | 25 | export default new Vuex.Store({ 26 | state: { 27 | keyPair: keyPair 28 | }, 29 | mutations: { 30 | login: (state, keys) => { 31 | localStorage.setItem(KEY, JSON.stringify(keys)) 32 | state.keyPair = keys 33 | }, 34 | logout: state => { 35 | localStorage.removeItem(KEY) 36 | state.keyPair = null 37 | } 38 | } 39 | }) 40 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/src/main/java/com/exonum/binding/cryptocurrency/CryptocurrencyServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.cryptocurrency; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | import com.google.inject.Singleton; 22 | import org.pf4j.Extension; 23 | 24 | @Extension 25 | public final class CryptocurrencyServiceModule extends AbstractServiceModule { 26 | 27 | @Override 28 | protected void configure() { 29 | bind(Service.class).to(CryptocurrencyServiceImpl.class); 30 | bind(CryptocurrencyService.class).to(CryptocurrencyServiceImpl.class).in(Singleton.class); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/src/main/java/com/exonum/binding/cryptocurrency/TransactionError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.cryptocurrency; 18 | 19 | enum TransactionError { 20 | WALLET_ALREADY_EXISTS(0), 21 | UNKNOWN_RECEIVER(1), 22 | UNKNOWN_SENDER(2), 23 | INSUFFICIENT_FUNDS(3), 24 | SAME_SENDER_AND_RECEIVER(4), 25 | NON_POSITIVE_TRANSFER_AMOUNT(5); 26 | 27 | final byte errorCode; 28 | 29 | TransactionError(int errorCode) { 30 | this.errorCode = (byte) errorCode; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/src/main/proto/transactions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.exonum.binding.cryptocurrency.transactions"; 4 | option java_outer_classname = "TxMessageProtos"; 5 | 6 | message TransferTx { 7 | int64 seed = 1; 8 | bytes toWallet = 2; 9 | int64 sum = 3; 10 | } 11 | 12 | message CreateWalletTx { 13 | int64 initialBalance = 1; 14 | } 15 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/src/main/proto/wallet.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.exonum.binding.cryptocurrency"; 4 | option java_outer_classname = "WalletProtos"; 5 | 6 | message Wallet { 7 | int64 balance = 1; 8 | } 9 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/src/test/java/com/exonum/binding/cryptocurrency/PredefinedOwnerKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.cryptocurrency; 18 | 19 | import com.exonum.binding.common.crypto.CryptoFunction; 20 | import com.exonum.binding.common.crypto.CryptoFunctions; 21 | import com.exonum.binding.common.crypto.KeyPair; 22 | 23 | public class PredefinedOwnerKeys { 24 | 25 | private static final CryptoFunction CRYPTO_FUNCTION = CryptoFunctions.ed25519(); 26 | 27 | public static final KeyPair FIRST_OWNER_KEY_PAIR = CRYPTO_FUNCTION.generateKeyPair(); 28 | public static final KeyPair SECOND_OWNER_KEY_PAIR = CRYPTO_FUNCTION.generateKeyPair(); 29 | 30 | private PredefinedOwnerKeys() { 31 | throw new AssertionError("Non-instantiable"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/src/test/java/com/exonum/binding/cryptocurrency/WalletSerializerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.cryptocurrency; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | class WalletSerializerTest { 24 | 25 | private WalletSerializer serializer = WalletSerializer.INSTANCE; 26 | 27 | @Test 28 | void roundTrip() { 29 | Wallet expectedWallet = testWallet(); 30 | 31 | byte[] bytes = serializer.toBytes(expectedWallet); 32 | Wallet actualWallet = serializer.fromBytes(bytes); 33 | 34 | assertThat(actualWallet).isEqualTo(expectedWallet); 35 | } 36 | 37 | private static Wallet testWallet() { 38 | return new Wallet(100L); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /exonum-java-binding/cryptocurrency-demo/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | # Use the mock maker that enables Mockito to mock _final_ classes. 2 | mock-maker-inline 3 | -------------------------------------------------------------------------------- /exonum-java-binding/doc/Migration_guide_0.7.md: -------------------------------------------------------------------------------- 1 | # Migrating Java Services to 0.7 2 | 3 | ## Update the Service 4 | 5 | ### Update the References to Moved Classes 6 | 7 | As some packages has been moved, the client code need to update the references. 8 | The following regular expression will do the job: 9 | 10 | ``` 11 | Find: (com.exonum.binding)(.)(annotations|blockchain|proxy|runtime|service|storage|transaction|transport|util) 12 | 13 | Replace: $1$2core$2$3 14 | ``` 15 | 16 | ## Explore the New Features 17 | 18 | 0.7.0 brings Exonum Testkit, which allows to test service operations in an emulated blockchain 19 | network. See the [documentation][testkit-documentation] for more information and examples. 20 | 21 | ## See Also 22 | 23 | The 0.7.0 [release page][release-page] for the changelog and pre-built binaries. 24 | 25 | [release-page]: https://github.com/exonum/exonum-java-binding/releases/tag/ejb/v0.7.0 26 | [testkit-documentation]: https://exonum.com/doc/version/0.12/get-started/java-binding/#testing 27 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated protobuf modules 2 | exonum_java_runtime_plugin/proto/ 3 | exonum_instance_configuration_plugin/proto/ 4 | 5 | # Python packaging and caches 6 | */__pycache__/ 7 | *.egg-info/ 8 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/README.md: -------------------------------------------------------------------------------- 1 | # Java Plugins for [Exonum Launcher](https://github.com/exonum/exonum-launcher) 2 | 3 | - Java Runtime Plugin allows to deploy and start Java services. 4 | - Instance Configuration Plugin allows to use an arbitrary Protobuf message for service 5 | initial configuration parameters. The plugin can be used for both Java and Rust services. 6 | 7 | ## Installation 8 | 9 | ### Requirements 10 | 11 | - [Python3](https://www.python.org/downloads/) 12 | 13 | ### Using PyPI 14 | 15 | ```bash 16 | pip3 install exonum-launcher-java-plugins 17 | ``` 18 | 19 | ### From Source 20 | 21 | ```bash 22 | # Generate sources 23 | source ./tests_profile 24 | mvn generate-sources -pl core 25 | # Install plugins 26 | python3 -m pip install -e exonum_launcher_java_plugins 27 | ``` 28 | 29 | ## Usage 30 | 31 | See [Deploy and Start the Service][deploy-and-start]. 32 | 33 | [deploy-and-start]: https://exonum.com/doc/version/1.0.0/get-started/java-binding/#deploy-and-start-the-service 34 | 35 | # License 36 | 37 | Apache License version 2.0. See [LICENSE](LICENSE) for details. 38 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/exonum_instance_configuration_plugin/__init__.py: -------------------------------------------------------------------------------- 1 | from .plugin import InstanceSpecLoader 2 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/exonum_java_runtime_plugin/__init__.py: -------------------------------------------------------------------------------- 1 | from .plugin import JavaDeploySpecLoader 2 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/exonum_java_runtime_plugin/plugin.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Exonum Team 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Dict, Any 16 | 17 | from exonum_launcher.runtimes.runtime import RuntimeSpecLoader 18 | 19 | try: 20 | from .proto.exonum.java import deploy_arguments_pb2 21 | except (ModuleNotFoundError, ImportError): 22 | raise RuntimeError("Protobuf definition is not found") 23 | 24 | 25 | class JavaDeploySpecLoader(RuntimeSpecLoader): 26 | """Artifact spec encoder for Java runtime""" 27 | 28 | def encode_spec(self, config: Dict[str, Any]) -> bytes: 29 | spec = deploy_arguments_pb2.DeployArguments() 30 | 31 | spec.artifact_filename = config["artifact_filename"] 32 | 33 | return spec.SerializeToString() 34 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/requirements.txt: -------------------------------------------------------------------------------- 1 | -e git+https://github.com/exonum/exonum-launcher@0cdd505bd0bf717f618012689293f61d9b675bf0#egg=exonum-launcher 2 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/sample-config.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 8080 5 | private-api-port: 8081 6 | 7 | deadline_height: 20000 8 | 9 | runtimes: 10 | java: 1 11 | 12 | plugins: 13 | runtime: 14 | java: "exonum_java_runtime_plugin.JavaDeploySpecLoader" 15 | artifact: 16 | timestamping: "exonum_instance_configuration_plugin.InstanceSpecLoader" 17 | 18 | artifacts: 19 | cryptocurrency: 20 | runtime: java 21 | name: "com.exonum.examples/cryptocurrency" 22 | version: "0.10.0" 23 | spec: 24 | artifact_filename: "exonum-java-binding-cryptocurrency-demo-0.10.0-artifact.jar" 25 | action: deploy 26 | time: 27 | runtime: rust 28 | name: "exonum-time" 29 | version: "1.0.0" 30 | timestamping: 31 | runtime: rust 32 | name: "exonum-timestamping" 33 | version: "1.0.0" 34 | 35 | instances: 36 | cryptocurrency: 37 | artifact: cryptocurrency 38 | action: start 39 | time: 40 | artifact: time 41 | action: start 42 | timestamping: 43 | artifact: timestamping 44 | config: 45 | sources: "proto_sources" 46 | config_message_source: "service.proto" 47 | message_name: "Config" 48 | data: 49 | time_service_name: "time" 50 | action: start 51 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exonum/exonum-java-binding/d02920311e6a3142738345f457e10a4ffa19a1a8/exonum-java-binding/exonum_launcher_java_plugins/tests/__init__.py -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/config.json: -------------------------------------------------------------------------------- 1 | {"some": ["json", {}]} 2 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/config.properties: -------------------------------------------------------------------------------- 1 | Truth=Beauty -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/config.txt: -------------------------------------------------------------------------------- 1 | text-configuration 2 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/custom_message_name.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 8080 5 | private-api-port: 8081 6 | 7 | plugins: 8 | artifact: 9 | timestamping: "exonum_instance_configuration_plugin.InstanceSpecLoader" 10 | 11 | deadline_height: 20000 12 | 13 | artifacts: 14 | timestamping: 15 | runtime: rust 16 | name: "exonum-timestamping" 17 | version: "0.12.0" 18 | 19 | instances: 20 | timestamping: 21 | artifact: timestamping 22 | config: 23 | sources: "test_data/proto_sources" 24 | config_message_source: "custom_message_name.proto" 25 | message_name: "InitialConfig" 26 | data: 27 | time_service_name: "testing" 28 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/instance_plugin.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 8080 5 | private-api-port: 8081 6 | 7 | plugins: 8 | artifact: 9 | timestamping: "exonum_instance_configuration_plugin.InstanceSpecLoader" 10 | 11 | deadline_height: 20000 12 | 13 | artifacts: 14 | timestamping: 15 | runtime: rust 16 | name: "exonum-timestamping" 17 | version: "0.12.0" 18 | 19 | instances: 20 | timestamping: 21 | artifact: timestamping 22 | config: 23 | sources: "test_data/proto_sources" 24 | config_message_source: "timestamping.proto" 25 | data: 26 | time_service_name: "testing" 27 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/invalid_config.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 8080 5 | private-api-port: 8081 6 | 7 | plugins: 8 | artifact: 9 | timestamping: "exonum_instance_configuration_plugin.InstanceSpecLoader" 10 | 11 | deadline_height: 20000 12 | 13 | artifacts: 14 | timestamping: 15 | runtime: rust 16 | name: "exonum-timestamping" 17 | version: "0.12.0" 18 | 19 | instances: 20 | no_config: 21 | artifact: timestamping 22 | empty_config: 23 | artifact: timestamping 24 | config: 25 | random_field: "" 26 | no_sources: 27 | artifact: timestamping 28 | config: 29 | config_message_source: "service.proto" 30 | data: 31 | time_service_name: "testing" 32 | no_module_name: 33 | artifact: timestamping 34 | config: 35 | sources: "test_data/proto_sources" 36 | data: 37 | time_service_name: "testing" 38 | no_data: 39 | artifact: timestamping 40 | config: 41 | sources: "test_data/proto_sources" 42 | config_message_source: "service.proto" 43 | standard_message_no_value: 44 | artifact: timestamping 45 | config: 46 | format: "text" 47 | standard_message_no_format: 48 | artifact: timestamping 49 | config: 50 | value: "text" 51 | standard_message_invalid_format: 52 | artifact: timestamping 53 | config: 54 | format: "not-supported-format" 55 | value: "text" 56 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/proto_sources/custom_message_name.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package exonum.examples.timestamping; 18 | 19 | message InitialConfig { 20 | string time_service_name = 1; 21 | } 22 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/proto_sources/timestamping.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Exonum Team 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package exonum.examples.timestamping; 18 | 19 | message Config { 20 | string time_service_name = 1; 21 | } 22 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/standard_message_json.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 8080 5 | private-api-port: 8081 6 | 7 | plugins: 8 | artifact: 9 | timestamping: "exonum_instance_configuration_plugin.InstanceSpecLoader" 10 | 11 | deadline_height: 20000 12 | 13 | artifacts: 14 | timestamping: 15 | runtime: rust 16 | name: "exonum-timestamping" 17 | version: "0.12.0" 18 | 19 | instances: 20 | json-in-place: 21 | artifact: timestamping 22 | config: 23 | format: "json" 24 | value: "{\"some\": [\"json\", {}]}\n" 25 | json-from-file: 26 | artifact: timestamping 27 | config: 28 | format: "json" 29 | from_file: "test_data/config.json" 30 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/standard_message_properties.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 8080 5 | private-api-port: 8081 6 | 7 | plugins: 8 | artifact: 9 | timestamping: "exonum_instance_configuration_plugin.InstanceSpecLoader" 10 | 11 | deadline_height: 20000 12 | 13 | artifacts: 14 | timestamping: 15 | runtime: rust 16 | name: "exonum-timestamping" 17 | version: "0.12.0" 18 | 19 | instances: 20 | properties-in-place: 21 | artifact: timestamping 22 | config: 23 | format: "properties" 24 | value: "Truth=Beauty" 25 | properties-from-file: 26 | artifact: timestamping 27 | config: 28 | format: "properties" 29 | from_file: "test_data/config.properties" 30 | -------------------------------------------------------------------------------- /exonum-java-binding/exonum_launcher_java_plugins/tests/test_data/standard_message_text.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | - host: "127.0.0.1" 3 | ssl: false 4 | public-api-port: 8080 5 | private-api-port: 8081 6 | 7 | plugins: 8 | artifact: 9 | timestamping: "exonum_instance_configuration_plugin.InstanceSpecLoader" 10 | 11 | deadline_height: 20000 12 | 13 | artifacts: 14 | timestamping: 15 | runtime: rust 16 | name: "exonum-timestamping" 17 | version: "0.12.0" 18 | 19 | instances: 20 | text-in-place: 21 | artifact: timestamping 22 | config: 23 | format: "text" 24 | value: "text-configuration\n" 25 | text-from-file: 26 | artifact: timestamping 27 | config: 28 | format: "text" 29 | from_file: "test_data/config.txt" 30 | -------------------------------------------------------------------------------- /exonum-java-binding/fake-service/src/main/java/com/exonum/binding/fakeservice/FakeServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.fakeservice; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | import com.google.inject.Singleton; 22 | import org.pf4j.Extension; 23 | 24 | /** 25 | * A module configuring {@link FakeService}. 26 | */ 27 | @Extension 28 | public final class FakeServiceModule extends AbstractServiceModule { 29 | 30 | @Override 31 | protected void configure() { 32 | bind(Service.class).to(FakeService.class) 33 | .in(Singleton.class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /exonum-java-binding/fake-service/src/main/proto/transactions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package exonum.fakeservice; 4 | 5 | option java_package = "com.exonum.binding.fakeservice"; 6 | 7 | message PutTransactionArgs { 8 | string key = 1; 9 | string value = 2; 10 | } 11 | 12 | message RaiseErrorArgs { 13 | uint32 code = 1; 14 | } 15 | -------------------------------------------------------------------------------- /exonum-java-binding/generate-javadocs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Builds an archive with Javadocs from published artifacts. 3 | # The archive is put in './target/site' 4 | 5 | # Fail immediately in case of errors and/or unset variables 6 | set -eu -o pipefail 7 | 8 | # Import necessary environment variables (see the tests_profile header comment for details). 9 | source tests_profile 10 | 11 | # The published modules for which Javadocs must be generated 12 | PROJECTS_TO_DOCUMENT="com.exonum.binding:exonum-java-binding-parent,messages,common,core,testkit,time-oracle" 13 | 14 | # Clean the project and install the artifacts in the local repository, 15 | # so that Javadocs can be generated for a subset of the modules — the published ones 16 | mvn clean install -DskipTests -DskipRustLibBuild --projects "${PROJECTS_TO_DOCUMENT}" --also-make 17 | 18 | # Generate the aggregated Javadocs for the published modules 19 | mvn javadoc:aggregate -Dmaven.javadoc.skip=false -DskipRustLibBuild \ 20 | `# Include *only* the published artifacts. As package filtering wildcards in Javadoc utility \ 21 | are rather limited, it is more convenient to specify the list of projects:` \ 22 | --projects "${PROJECTS_TO_DOCUMENT}" 23 | 24 | # Create an archive to be published 25 | TARGET="${PWD}/target/site/" 26 | cd "${TARGET}" 27 | 28 | ARCHIVE_NAME="java-binding-apidocs.zip" 29 | zip -r ${ARCHIVE_NAME} "apidocs" 30 | 31 | echo "[INFO] Javadoc archive created in ${TARGET}/${ARCHIVE_NAME}" 32 | -------------------------------------------------------------------------------- /exonum-java-binding/integration-tests/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /exonum-java-binding/integration-tests/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /exonum-java-binding/qa-service/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /exonum-java-binding/qa-service/src/main/java/com/exonum/binding/qaservice/QaExecutionError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.qaservice; 18 | 19 | import com.google.common.primitives.UnsignedBytes; 20 | 21 | enum QaExecutionError { 22 | // Create counter errors 23 | COUNTER_ALREADY_EXISTS(0), 24 | // Increment counter errors 25 | UNKNOWN_COUNTER(1), 26 | // Empty time oracle name supplied in the configuration 27 | EMPTY_TIME_ORACLE_NAME(2), 28 | // Error appeared while service resume 29 | RESUME_SERVICE_ERROR(3); 30 | 31 | final byte code; 32 | 33 | QaExecutionError(int code) { 34 | this.code = UnsignedBytes.checkedCast(code); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /exonum-java-binding/qa-service/src/main/java/com/exonum/binding/qaservice/QaServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.qaservice; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | import com.google.inject.Singleton; 22 | import org.pf4j.Extension; 23 | 24 | /** 25 | * A module of the QA service. 26 | */ 27 | @Extension 28 | public final class QaServiceModule extends AbstractServiceModule { 29 | 30 | @Override 31 | protected void configure() { 32 | bind(Service.class).to(QaServiceImpl.class); 33 | bind(QaService.class).to(QaServiceImpl.class); 34 | // Make sure QaService remains a singleton. 35 | bind(QaServiceImpl.class).in(Singleton.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/qa-service/src/main/proto/config.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package exonum.qa; 4 | 5 | option java_package = "com.exonum.binding.qaservice"; 6 | 7 | // QA service configuration parameters. 8 | message QaConfiguration { 9 | // The name of a time oracle service instance to use. 10 | string time_oracle_name = 1; 11 | } 12 | 13 | // Parameters to use in the QA service resume. 14 | message QaResumeArguments { 15 | // name of the counter to create 16 | string counter_name = 1; 17 | // Identifies either to throw execution exception or not. 18 | bool should_throw_exception = 2; 19 | } 20 | -------------------------------------------------------------------------------- /exonum-java-binding/qa-service/src/main/proto/transactions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package exonum.qa; 4 | 5 | option java_package = "com.exonum.binding.qaservice.transactions"; 6 | option java_outer_classname = "TxMessageProtos"; 7 | 8 | message CreateCounterTxBody { 9 | string name = 1; 10 | } 11 | 12 | message IncrementCounterTxBody { 13 | uint64 seed = 1; 14 | string counterName = 3; 15 | } 16 | 17 | message ThrowingTxBody { 18 | uint64 seed = 1; 19 | } 20 | 21 | message ErrorTxBody { 22 | uint64 seed = 1; 23 | // Effectively will always be stored as a single byte, 24 | // since it is in range [0; 127]. 25 | int32 errorCode = 2; 26 | string errorDescription = 3; 27 | } 28 | -------------------------------------------------------------------------------- /exonum-java-binding/qa-service/src/test/java/com/exonum/binding/qaservice/CounterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.qaservice; 18 | 19 | import nl.jqno.equalsverifier.EqualsVerifier; 20 | import org.junit.jupiter.api.Test; 21 | 22 | class CounterTest { 23 | 24 | @Test 25 | void verifyEquals() { 26 | EqualsVerifier.forClass(Counter.class) 27 | .verify(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exonum-java-binding/qa-service/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /exonum-java-binding/qa-service/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | # Use the mock maker that enables Mockito to mock _final_ classes. 2 | mock-maker-inline 3 | -------------------------------------------------------------------------------- /exonum-java-binding/run_all_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs all tests in the EJB project. 3 | # The main purpose of this file is to run all EJB tests from the EJB parent directory. 4 | # This file should be always synchronized with ../run_all_tests.sh for correct work. 5 | # 6 | # A JVM will be selected by JAVA_HOME environment variable, or, if it is not set, 7 | # inferred from the java executable available on the path. 8 | 9 | # Fail immediately in case of errors and/or unset variables 10 | set -eu -o pipefail 11 | 12 | # Run all java tests and native unit tests. 13 | ./run_maven_tests.sh 14 | 15 | # Run native integration tests that require prepared classpaths for Java classes. 16 | ./run_native_integration_tests.sh --skip-compile 17 | ./run_app_tests.sh 18 | 19 | # Run tutorials tests 20 | ./run_tutorials_tests.sh 21 | -------------------------------------------------------------------------------- /exonum-java-binding/run_app_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs Exonum Java app tests (ejb-core/rust/exonum-java). 3 | # 4 | # ¡Keep it MacOS/Ubuntu compatible! 5 | 6 | # Fail immediately in case of errors and/or unset variables 7 | set -eu -o pipefail 8 | 9 | # Import necessary environment variables (see the tests_profile header comment for details). 10 | source tests_profile 11 | 12 | cd core/rust 13 | 14 | cargo "+${RUST_COMPILER_VERSION}" test \ 15 | --manifest-path exonum-java/Cargo.toml 16 | -------------------------------------------------------------------------------- /exonum-java-binding/run_maven_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Run all java tests and native unit tests. 3 | 4 | # Fail immediately in case of errors and/or unset variables 5 | set -eu -o pipefail 6 | 7 | # Import necessary environment variables (see the tests_profile header comment for details). 8 | source tests_profile 9 | 10 | # Run unit and integration tests in ci-build profile. This profile includes: 11 | # - Java unit & integration tests, including ci-only & slow non-critical tests, 12 | # which are excluded in the default profile. 13 | # - Checkstyle checks as errors. 14 | # - Native unit & integration tests that do not require a JVM. 15 | # - Test coverage information collection. 16 | # See build definitions of the modules for more. 17 | mvn install \ 18 | --activate-profiles ci-build \ 19 | -Drust.compiler.version="${RUST_COMPILER_VERSION}" 20 | -------------------------------------------------------------------------------- /exonum-java-binding/run_native_integration_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs native integration tests (those in ejb-core/rust/integration_tests). 3 | # If --skip-compile is passed, does not recompile all Java sources. 4 | # 5 | # ¡Keep it MacOS/Ubuntu compatible! 6 | 7 | # Fail immediately in case of errors and/or unset variables. 8 | set -eu -o pipefail 9 | 10 | # Import necessary environment variables (see the tests_profile header comment for details). 11 | source tests_profile 12 | 13 | # Compile all Java modules by default to ensure that ejb-core module, which is required 14 | # by native ITs, is up-to-date. This safety net takes about a dozen seconds, 15 | # so if the Java artefacts are definitely up-to-date, it may be skipped. 16 | if [ "$#" -eq 0 ]; then 17 | # Compile Java artefacts. 18 | echo "Compiling the Java artefacts…" 19 | mvn compile --quiet -pl core -am 20 | else 21 | if [ "$1" != "--skip-compile" ]; then 22 | echo "Unknown option: $1" 23 | exit 1 24 | fi 25 | fi 26 | 27 | cd core/rust 28 | 29 | cargo "+${RUST_COMPILER_VERSION}" test \ 30 | --manifest-path integration_tests/Cargo.toml 31 | -------------------------------------------------------------------------------- /exonum-java-binding/run_tutorials_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Run tutorial tests in development mode (i.e., with a java_bindings library in 3 | # core/target/debug). To run them with an installed application, simply invoke `mvn verify`. 4 | 5 | # Fail immediately in case of errors and/or unset variables 6 | set -eu -o pipefail 7 | 8 | # Warn on set EXONUM_HOME 9 | if [[ "${EXONUM_HOME:-}" != "" ]]; then 10 | echo "[WARNING] EXONUM_HOME is set and will be ignored: ${EXONUM_HOME}" 11 | echo "[WARNING] If you need to run the tests with an installed application, use mvn verify" 12 | fi 13 | 14 | # Check the native lib path exists 15 | NATIVE_LIB_PATH="${PWD}/core/rust/target/debug" 16 | if [[ ! -d "$NATIVE_LIB_PATH" ]]; then 17 | echo "[ERROR] The native library path does not exist: $NATIVE_LIB_PATH" 18 | echo "[ERROR] Check you run the script from EJB root. If that's correct, then build 19 | the EJB first." 20 | exit 1 21 | fi 22 | 23 | # Run the tests 24 | mvn verify -DnativeLibPath="$NATIVE_LIB_PATH" -f tutorials 25 | -------------------------------------------------------------------------------- /exonum-java-binding/service-archetype/src/main/resources/archetype-resources/README.md: -------------------------------------------------------------------------------- 1 | ## Double pound sign starts a comment in the Velocity template 2 | ## engine used under the hood. 3 | ## Below we use _directives_ to be able to produce a Markdown document: 4 | ## https://velocity.apache.org/engine/1.7/user-guide.html#literals 5 | #set($h1 = '#') 6 | #set($h2 = '##') 7 | #set($h3 = '###') 8 | #set($h4 = '####') 9 | 10 | $h1 ${rootArtifactId} 11 | 12 | An Exonum service. 13 | 14 | $h2 Project Structure 15 | 16 | The project consist of the following modules: 17 | 18 | - `${rootArtifactId}-messages`. Defines the service transaction arguments and 19 | persistent data as Protocol Buffers messages. 20 | May also be used from client applications. 21 | - `${rootArtifactId}-service`. Contains the service implementation. 22 | This module produces the _service artifact_. 23 | 24 | $h2 How to Build 25 | 26 | $h3 Prerequisites 27 | 28 | - [Exonum Java][ejb-installation] 29 | - Apache Maven 30 | - JDK 11+ 31 | 32 | [ejb-installation]: https://exonum.com/doc/version/latest/get-started/java-binding/#installation 33 | 34 | $h3 Building 35 | 36 | To build the service artifact, invoke: 37 | 38 | ```shell 39 | mvn package 40 | ``` 41 | 42 | To also run the integration tests, invoke: 43 | 44 | ```shell 45 | mvn verify 46 | ``` 47 | -------------------------------------------------------------------------------- /exonum-java-binding/service-archetype/src/main/resources/archetype-resources/__rootArtifactId__-messages/src/main/proto/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exonum/exonum-java-binding/d02920311e6a3142738345f457e10a4ffa19a1a8/exonum-java-binding/service-archetype/src/main/resources/archetype-resources/__rootArtifactId__-messages/src/main/proto/.gitkeep -------------------------------------------------------------------------------- /exonum-java-binding/service-archetype/src/main/resources/archetype-resources/__rootArtifactId__-service/src/main/java/MyService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ${package}; 18 | 19 | import com.exonum.binding.core.runtime.ServiceInstanceSpec; 20 | import com.exonum.binding.core.service.AbstractService; 21 | import com.exonum.binding.core.service.Node; 22 | import com.google.inject.Inject; 23 | import io.vertx.ext.web.Router; 24 | 25 | public final class MyService extends AbstractService { 26 | 27 | @Inject 28 | public MyService(ServiceInstanceSpec instanceSpec) { 29 | super(instanceSpec); 30 | } 31 | 32 | @Override 33 | public void createPublicApiHandlers(Node node, Router router) {} 34 | } 35 | -------------------------------------------------------------------------------- /exonum-java-binding/service-archetype/src/main/resources/archetype-resources/__rootArtifactId__-service/src/main/java/ServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ${package}; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | import com.google.inject.Singleton; 22 | import org.pf4j.Extension; 23 | 24 | /** 25 | * A service module defines bindings required to create an instance of {@link MyService}. 26 | */ 27 | @Extension 28 | public final class ServiceModule extends AbstractServiceModule { 29 | 30 | @Override 31 | protected void configure() { 32 | bind(Service.class).to(MyService.class).in(Singleton.class); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /exonum-java-binding/service-archetype/src/main/resources/archetype-resources/deploy-start-config.yml: -------------------------------------------------------------------------------- 1 | # An exonum-launcher configuration file for deploying and starting a service instance 2 | # in the test network. Edit as needed. 3 | # 4 | # See: 5 | # - start-testnet.sh 6 | # - https://exonum.com/doc/version/latest/get-started/java-binding/#deploy-and-start-the-service 7 | networks: 8 | - host: "127.0.0.1" 9 | ssl: false 10 | public-api-port: 3000 11 | private-api-port: 3010 12 | 13 | deadline_height: 20000 14 | 15 | runtimes: 16 | java: 1 17 | 18 | plugins: 19 | runtime: 20 | java: "exonum_java_runtime_plugin.JavaDeploySpecLoader" 21 | 22 | artifacts: 23 | ${rootArtifactId}: 24 | runtime: java 25 | name: "${groupId}/${rootArtifactId}-service" 26 | version: "${version}" 27 | spec: 28 | artifact_filename: "${rootArtifactId}-service-${version}-artifact.jar" 29 | action: deploy 30 | 31 | instances: 32 | # A test service instance of "${rootArtifactId}-service". 33 | test-${artifactId}: 34 | artifact: ${artifactId} 35 | action: start 36 | -------------------------------------------------------------------------------- /exonum-java-binding/service-archetype/src/test/resources/projects/archetype.properties: -------------------------------------------------------------------------------- 1 | sourceEncoding=UTF-8 2 | groupId=com.exonum.binding.archetype.test 3 | artifactId=integration-test 4 | version=1.0.0 5 | package=com.exonum.binding.archetype.test.custom 6 | -------------------------------------------------------------------------------- /exonum-java-binding/service-archetype/src/test/resources/projects/goal.txt: -------------------------------------------------------------------------------- 1 | verify 2 | -------------------------------------------------------------------------------- /exonum-java-binding/site-examples/README.md: -------------------------------------------------------------------------------- 1 | # Site Examples 2 | 3 | `site-examples` contains code examples that are included into the documentation 4 | pages from [`exonum-doc`](https://github.com/exonum/exonum-doc). 5 | _The example code is **not** supposed to work as standalone, self-contained 6 | examples_. 7 | -------------------------------------------------------------------------------- /exonum-java-binding/site-examples/src/main/java/com/exonum/binding/example/guide/ProofMapCreation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.example.guide; 18 | 19 | import com.exonum.binding.common.serialization.StandardSerializers; 20 | import com.exonum.binding.core.storage.database.Prefixed; 21 | import com.exonum.binding.core.storage.indices.IndexAddress; 22 | 23 | @SuppressWarnings("unused") // Example code 24 | class ProofMapCreation { 25 | 26 | void putEntry(Prefixed access, String key, String value) { 27 | // Access the 'entries' ProofMap 28 | var indexAddress = IndexAddress.valueOf("entries"); 29 | var stringSerializer = StandardSerializers.string(); 30 | var entries = access.getProofMap(indexAddress, stringSerializer, 31 | stringSerializer); 32 | // Put the key-value pair in the ProofMap index 33 | entries.put(key, value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /exonum-java-binding/site-examples/src/main/java/com/exonum/binding/example/guide/ServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.example.guide; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | import org.pf4j.Extension; 22 | 23 | @SuppressWarnings("unused") // Example code 24 | // ci-block ci_service_module { 25 | @Extension 26 | public final class ServiceModule extends AbstractServiceModule { 27 | 28 | @Override 29 | protected void configure() { 30 | // Define the Service implementation 31 | bind(Service.class).to(FooService.class); 32 | } 33 | } 34 | // } 35 | -------------------------------------------------------------------------------- /exonum-java-binding/site-examples/src/main/proto/example/guide/transactions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package example.guide; 4 | 5 | option java_package = "com.exonum.binding.example.guide"; 6 | 7 | message PutEntryArgs { 8 | string key = 1; 9 | string value = 2; 10 | } 11 | -------------------------------------------------------------------------------- /exonum-java-binding/testing/src/main/java/com/exonum/binding/test/CiOnly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.binding.test; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Inherited; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | import org.junit.jupiter.api.Tag; 26 | 27 | /** 28 | * Annotation for long running tests for excluding them from the build flow for default profile. 29 | * Tests with this annotation executes as usual at CI ("ci-build" maven profile). 30 | */ 31 | @Target({ElementType.TYPE, ElementType.METHOD}) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Inherited 34 | @Tag("slow-test") 35 | public @interface CiOnly { 36 | } 37 | -------------------------------------------------------------------------------- /exonum-java-binding/testing/src/main/java/com/exonum/binding/test/Integration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.test; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.Tag; 25 | 26 | /** 27 | * Indicates that a test is an integration test. Tags the annotated test with "integration" 28 | * tag. 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | @Tag("integration") 34 | public @interface Integration { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /exonum-java-binding/testing/src/main/java/com/exonum/binding/test/RequiresNativeLibrary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.test; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.Tag; 25 | 26 | /** 27 | * Indicates that a test requires the native Java Binding library to work. 28 | */ 29 | @Target({ ElementType.TYPE, ElementType.METHOD }) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Inherited 32 | @Tag("requires-native-library") 33 | public @interface RequiresNativeLibrary { 34 | } 35 | -------------------------------------------------------------------------------- /exonum-java-binding/testing/src/test/java/com/exonum/binding/test/runtime/TestService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.test.runtime; 18 | 19 | class TestService { 20 | static class Inner {} 21 | } 22 | -------------------------------------------------------------------------------- /exonum-java-binding/testing/src/test/java/com/exonum/binding/test/runtime/testplugin/TestPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.test.runtime.testplugin; 18 | 19 | import org.pf4j.Plugin; 20 | import org.pf4j.PluginWrapper; 21 | 22 | public class TestPlugin extends Plugin { 23 | 24 | public TestPlugin(PluginWrapper wrapper) { 25 | super(wrapper); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /exonum-java-binding/testing/src/test/java/com/exonum/binding/test/runtime/testplugin/TestServiceExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.test.runtime.testplugin; 18 | 19 | import org.pf4j.ExtensionPoint; 20 | 21 | public interface TestServiceExtension extends ExtensionPoint { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /exonum-java-binding/testing/src/test/java/com/exonum/binding/test/runtime/testplugin/TestServiceExtensionImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.test.runtime.testplugin; 18 | 19 | public class TestServiceExtensionImpl implements TestServiceExtension { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/README.md: -------------------------------------------------------------------------------- 1 | # TestKit 2 | 3 | Exonum Java Binding provides a powerful testing toolkit - TestKit. 4 | TestKit allows testing transaction execution in the synchronous environment by offering simple 5 | network emulation (that is, without consensus algorithm and network operation involved). 6 | 7 | For more details and a guide on how to use TestKit in your tests, see 8 | [documentation][exonum-testkit]. 9 | 10 | ## License 11 | 12 | `exonum-testkit` is licensed under the 13 | Apache License (Version 2.0). 14 | See [LICENSE](../../LICENSE) for details. 15 | 16 | [exonum-testkit]: https://exonum.com/doc/version/1.0.0/get-started/java-binding/#testing 17 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/main/java/com/exonum/binding/testkit/Auditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Changes main TestKit node type to auditor for injected TestKit. 26 | * 27 | * @see TestKit.Builder#withNodeType(EmulatedNodeType) 28 | * @see Auditor Node 29 | */ 30 | @Target(ElementType.PARAMETER) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Auditor { 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/main/java/com/exonum/binding/testkit/EmulatedNodeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | /** 20 | * Type of the TestKit emulated node. 21 | * 22 | * @see Auditor Node 23 | * @see Validator Node 24 | */ 25 | public enum EmulatedNodeType { 26 | VALIDATOR, 27 | AUDITOR 28 | } 29 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/main/java/com/exonum/binding/testkit/TimeProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import java.time.Clock; 20 | import java.time.ZoneOffset; 21 | import java.time.ZonedDateTime; 22 | 23 | /** 24 | * Time provider for service testing. Used as a time source by TestKit time service. 25 | */ 26 | public interface TimeProvider { 27 | 28 | /** 29 | * Returns the current time of this time provider in UTC time zone. 30 | */ 31 | ZonedDateTime getTime(); 32 | 33 | /** 34 | * Returns a provider that uses the {@linkplain Clock#system system time}. 35 | */ 36 | static TimeProvider systemTime() { 37 | return () -> ZonedDateTime.now(ZoneOffset.UTC); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/main/java/com/exonum/binding/testkit/TimeServiceSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | /** 20 | * A specification of a time service instance used by TestKit for service creation. 21 | */ 22 | @SuppressWarnings({"unused", "WeakerAccess"}) // Native API 23 | class TimeServiceSpec { 24 | 25 | final TimeProviderAdapter timeProvider; 26 | final String serviceName; 27 | final int serviceId; 28 | 29 | TimeServiceSpec(String serviceName, int serviceId, TimeProviderAdapter timeProvider) { 30 | this.serviceName = serviceName; 31 | this.serviceId = serviceId; 32 | this.timeProvider = timeProvider; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/main/java/com/exonum/binding/testkit/Validator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Changes main TestKit node type to validator for injected TestKit. 26 | * 27 | * @see TestKit.Builder#withNodeType(EmulatedNodeType) 28 | * @see Validator Node 29 | */ 30 | @Target(ElementType.PARAMETER) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Validator { 33 | } 34 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/main/java/com/exonum/binding/testkit/ValidatorCount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Number of validator nodes in the TestKit network, should be positive. Note that regardless of 26 | * the configured number of validators, only a single service will be instantiated. 27 | * 28 | * @see TestKit.Builder#withValidators(short) 29 | */ 30 | @Target(ElementType.PARAMETER) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface ValidatorCount { 33 | 34 | /** 35 | * Validator count of TestKit network. 36 | */ 37 | short value(); 38 | } 39 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/test/java/com/exonum/binding/testkit/SystemTimeProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.time.ZoneOffset; 22 | import java.time.ZonedDateTime; 23 | import org.junit.jupiter.api.Test; 24 | 25 | class SystemTimeProviderTest { 26 | 27 | @Test 28 | void systemTimeProvidesCurrentTimeInUtc() { 29 | TimeProvider systemTime = TimeProvider.systemTime(); 30 | 31 | ZonedDateTime before = ZonedDateTime.now(ZoneOffset.UTC); 32 | ZonedDateTime provided = systemTime.getTime(); 33 | ZonedDateTime after = ZonedDateTime.now(ZoneOffset.UTC); 34 | 35 | // Check that the provided time uses the UTC time zone and the current time 36 | assertThat(provided).isBetween(before, after); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/test/java/com/exonum/binding/testkit/TestSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import static com.exonum.binding.common.serialization.StandardSerializers.string; 20 | 21 | import com.exonum.binding.core.service.Schema; 22 | import com.exonum.binding.core.storage.database.Access; 23 | import com.exonum.binding.core.storage.indices.IndexAddress; 24 | import com.exonum.binding.core.storage.indices.ProofMapIndexProxy; 25 | 26 | final class TestSchema implements Schema { 27 | 28 | private static final IndexAddress TEST_MAP_ADDRESS = IndexAddress.valueOf("TestKitService_map"); 29 | 30 | private final Access access; 31 | 32 | TestSchema(Access access) { 33 | this.access = access; 34 | } 35 | 36 | ProofMapIndexProxy testMap() { 37 | return access.getProofMap(TEST_MAP_ADDRESS, string(), string()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/test/java/com/exonum/binding/testkit/TestService2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import com.exonum.binding.core.runtime.ServiceInstanceSpec; 20 | import com.exonum.binding.core.service.AbstractService; 21 | import com.exonum.binding.core.service.Node; 22 | import com.google.inject.Inject; 23 | import io.vertx.ext.web.Router; 24 | 25 | public final class TestService2 extends AbstractService { 26 | 27 | @Inject 28 | public TestService2(ServiceInstanceSpec serviceSpec) { 29 | super(serviceSpec); 30 | } 31 | 32 | @Override 33 | public void createPublicApiHandlers(Node node, Router router) { 34 | // No handlers 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/test/java/com/exonum/binding/testkit/TestServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | import com.google.inject.Singleton; 22 | 23 | public final class TestServiceModule extends AbstractServiceModule { 24 | 25 | @Override 26 | protected void configure() { 27 | bind(Service.class).to(TestService.class).in(Singleton.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/test/java/com/exonum/binding/testkit/TestServiceModule2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.binding.testkit; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | import com.google.inject.Singleton; 22 | 23 | public final class TestServiceModule2 extends AbstractServiceModule { 24 | 25 | @Override 26 | protected void configure() { 27 | bind(Service.class).to(TestService2.class).in(Singleton.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/test/proto/TestMessages.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.exonum.binding.testkit"; 4 | option java_outer_classname = "TestProtoMessages"; 5 | 6 | message TestConfiguration { 7 | string value = 1; 8 | } 9 | -------------------------------------------------------------------------------- /exonum-java-binding/testkit/src/test/proto/transactions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package exonum.testkit; 4 | 5 | option java_package = "com.exonum.binding.testkit"; 6 | 7 | message PutTransactionArgs { 8 | string key = 1; 9 | string value = 2; 10 | } 11 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/.gitignore: -------------------------------------------------------------------------------- 1 | # The dir used by test Exonum network 2 | testnet/ 3 | 4 | # venv for Python modules 5 | .venv/ 6 | 7 | # Exonum key files that the CLI client uses 8 | exonum_id* 9 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/README.md: -------------------------------------------------------------------------------- 1 | # car-registry 2 | 3 | Exonum vehicle registry service for a [tutorial][car-registry-tutorial] 4 | on Java service development. 5 | 6 | [car-registry-tutorial]: https://exonum.com/doc/version/1.0.0/get-started/first-java-service/ 7 | 8 | ## Project Structure 9 | 10 | The project consist of the following modules: 11 | 12 | - `car-registry-messages`. Defines the service transaction arguments and 13 | persistent data as Protocol Buffers messages. 14 | May also be used from client applications. 15 | - `car-registry-service`. Contains the service implementation. 16 | This module produces the _service artifact_. 17 | - `car-registry-client`. Contains a CLI client for the service. 18 | 19 | ## How to Build 20 | 21 | ### Prerequisites 22 | 23 | - [Exonum Java][ejb-installation] 24 | - Apache Maven 25 | - JDK 11+ 26 | 27 | [ejb-installation]: https://exonum.com/doc/version/1.0.0/get-started/java-binding/#installation 28 | 29 | ### Building 30 | 31 | To build the service artifact, invoke: 32 | 33 | ```shell 34 | mvn package 35 | ``` 36 | 37 | To also run the integration tests, invoke: 38 | 39 | ```shell 40 | mvn verify 41 | ``` 42 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/car-registry-client/src/main/java/com/example/car/client/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.car.client; 18 | 19 | /** 20 | * The client application rudimentary configuration. 21 | */ 22 | final class Config { 23 | static final String NODE_PUBLIC_API_HOST = "http://127.0.0.1:3000"; 24 | static final String NODE_JAVA_API_HOST = "http://127.0.0.1:7000"; 25 | 26 | private Config() {} 27 | } 28 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/car-registry-client/src/main/java/com/example/car/client/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.car.client; 18 | 19 | import java.util.concurrent.Callable; 20 | import picocli.CommandLine; 21 | import picocli.CommandLine.Command; 22 | 23 | /** 24 | * The main command of the car registry client. 25 | */ 26 | @Command( 27 | subcommands = { 28 | AddVehicleCommand.class, 29 | ChangeOwnerCommand.class, 30 | FindVehicleCommand.class, 31 | GenerateKeyCommand.class, 32 | }, 33 | mixinStandardHelpOptions = true 34 | ) 35 | public class Main implements Callable { 36 | 37 | public static void main(String[] args) { 38 | int exitCode = new CommandLine(new Main()).execute(args); 39 | System.exit(exitCode); 40 | } 41 | 42 | @Override 43 | public Integer call() { 44 | return 0; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/car-registry-client/src/main/java/com/example/car/client/ServiceIds.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.car.client; 18 | 19 | import picocli.CommandLine.Option; 20 | 21 | final class ServiceIds { 22 | @Option(names = {"-n", "--service-name"}, 23 | description = "The service instance name.") 24 | String name; 25 | 26 | @Option(names = {"-i", "--service-id"}, 27 | description = "The numeric service instance ID, assigned on the instance start.") 28 | Integer id; 29 | 30 | boolean hasName() { 31 | return name != null; 32 | } 33 | 34 | boolean hasId() { 35 | return id != null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/car-registry-messages/src/main/proto/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exonum/exonum-java-binding/d02920311e6a3142738345f457e10a4ffa19a1a8/exonum-java-binding/tutorials/car-registry/car-registry-messages/src/main/proto/.gitkeep -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/car-registry-messages/src/main/proto/example/vehicle/transactions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package example.vehicle; 4 | 5 | option java_package = "com.example.car.messages"; 6 | 7 | // ci-block ci-add-vehicle { 8 | import "example/vehicle/vehicle.proto"; 9 | 10 | message AddVehicle { 11 | Vehicle new_vehicle = 1; 12 | } 13 | // } 14 | 15 | message ChangeOwner { 16 | string id = 1; 17 | string new_owner = 2; 18 | } 19 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/car-registry-messages/src/main/proto/example/vehicle/vehicle.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package example.vehicle; 4 | 5 | option java_package = "com.example.car.messages"; 6 | 7 | message Vehicle { 8 | string id = 1; 9 | string make = 2; 10 | string model = 3; 11 | string owner = 4; 12 | } 13 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/car-registry-service/src/main/java/com/example/car/ServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.car; 18 | 19 | import com.exonum.binding.core.service.AbstractServiceModule; 20 | import com.exonum.binding.core.service.Service; 21 | import com.google.inject.Singleton; 22 | import org.pf4j.Extension; 23 | 24 | /** 25 | * A service module defines bindings required to create an instance of {@link MyService}. 26 | */ 27 | @Extension 28 | public final class ServiceModule extends AbstractServiceModule { 29 | 30 | @Override 31 | protected void configure() { 32 | bind(Service.class).to(MyService.class).in(Singleton.class); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/car-registry/deploy-start-config.yml: -------------------------------------------------------------------------------- 1 | # An exonum-launcher configuration file for deploying and starting a service instance 2 | # in the test network. Edit as needed. 3 | # 4 | # See: 5 | # - start-testnet.sh 6 | # - https://exonum.com/doc/version/1.0.0/get-started/java-binding/#deploy-and-start-the-service 7 | networks: 8 | - host: "127.0.0.1" 9 | ssl: false 10 | public-api-port: 3000 11 | private-api-port: 3010 12 | 13 | deadline_height: 20000 14 | 15 | runtimes: 16 | java: 1 17 | 18 | plugins: 19 | runtime: 20 | java: "exonum_java_runtime_plugin.JavaDeploySpecLoader" 21 | 22 | artifacts: 23 | car-registry: 24 | runtime: java 25 | name: "com.example.car/car-registry-service" 26 | version: "1.0.0-SNAPSHOT" 27 | spec: 28 | artifact_filename: "car-registry-service-1.0.0-SNAPSHOT-artifact.jar" 29 | action: deploy 30 | 31 | instances: 32 | # A test service instance of "car-registry-service". 33 | test-car-registry: 34 | artifact: car-registry 35 | action: start 36 | -------------------------------------------------------------------------------- /exonum-java-binding/tutorials/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.exonum.binding 6 | exonum-java-tutorials-parent 7 | 1.0.0 8 | pom 9 | 10 | Exonum Java Tutorials: Parent 11 | 12 | The parent project of the Exonum Java tutorials. 13 | 14 | 15 | 16 | car-registry 17 | 18 | 19 | 20 | UTF-8 21 | UTF-8 22 | 23 | 24 | -------------------------------------------------------------------------------- /exonum-light-client/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -XX:TieredStopAtLevel=1 -XX:+UseParallelGC -------------------------------------------------------------------------------- /exonum-light-client/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /exonum-light-client/generate-javadocs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Builds an archive with Javadocs from published artifacts. 3 | # The archive is put in './target/site' 4 | 5 | # Fail immediately in case of errors and/or unset variables 6 | set -eu -o pipefail 7 | 8 | # Generate the aggregated Javadocs for the published modules 9 | mvn clean javadoc:javadoc -Dmaven.javadoc.skip=false 10 | 11 | # Create an archive to be published 12 | TARGET="${PWD}/target/site/" 13 | cd "${TARGET}" 14 | 15 | ARCHIVE_NAME="light-client-apidocs.tgz" 16 | tar cvaf "${ARCHIVE_NAME}" "apidocs/" 17 | 18 | echo "[INFO] Javadoc archive created in ${TARGET}/${ARCHIVE_NAME}" 19 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/java/com/exonum/client/ExonumApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client; 18 | 19 | import com.exonum.binding.common.serialization.json.JsonSerializer; 20 | import com.google.gson.FieldNamingPolicy; 21 | import com.google.gson.Gson; 22 | 23 | final class ExonumApi { 24 | /** 25 | * The Gson instance configured to (de)serialize Exonum responses. 26 | */ 27 | static final Gson JSON = JsonSerializer.builder() 28 | .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) 29 | .create(); 30 | 31 | /** 32 | * The maximum allowed blocks count per the request. 33 | */ 34 | static final int MAX_BLOCKS_PER_REQUEST = 1000; 35 | 36 | 37 | private ExonumApi() { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/java/com/exonum/client/ExonumIterables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client; 18 | 19 | import com.google.common.collect.Iterables; 20 | import java.util.OptionalInt; 21 | import java.util.function.Predicate; 22 | 23 | final class ExonumIterables { 24 | 25 | /** 26 | * Returns an index of the first element matching the predicate or {@code OptionalInt.empty()} 27 | * if no such element exists. 28 | * 29 | * @param list a list to search in 30 | * @param p a predicate that an element must match 31 | * @param the type of elements 32 | */ 33 | static OptionalInt indexOf(Iterable list, Predicate p) { 34 | int i = Iterables.indexOf(list, p::test); 35 | if (i == -1) { 36 | return OptionalInt.empty(); 37 | } 38 | return OptionalInt.of(i); 39 | } 40 | 41 | private ExonumIterables() {} 42 | } 43 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/java/com/exonum/client/ExonumUrls.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.exonum.client; 19 | 20 | /** 21 | * Contains Exonum API URLs. 22 | */ 23 | final class ExonumUrls { 24 | private static final String EXPLORER_PATHS_PREFIX = "api/explorer/v1"; 25 | private static final String SUPERVISOR_PATHS_PREFIX = "api/services/supervisor"; 26 | static final String TRANSACTIONS = EXPLORER_PATHS_PREFIX + "/transactions"; 27 | static final String BLOCK = EXPLORER_PATHS_PREFIX + "/block"; 28 | static final String BLOCKS = EXPLORER_PATHS_PREFIX + "/blocks"; 29 | static final String SERVICES = SUPERVISOR_PATHS_PREFIX + "/services"; 30 | 31 | private ExonumUrls() {} 32 | } 33 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/java/com/exonum/client/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The Exonum light client. 19 | * Can be used to submit transactions to the Exonum blockchain. 20 | * The following example shows how to instantiate the client and submit transaction: 21 | *

22 |  *   {@code
23 |  *       ExonumClient exonumClient = ExonumClient.newBuilder()
24 |  *         .setExonumHost("http://:")
25 |  *         .build();
26 |  *       exonumClient.submitTransaction(tx);
27 |  *   }
28 |  * 
29 | * 30 | *

See more examples in the project readme. 31 | */ 32 | package com.exonum.client; 33 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/java/com/exonum/client/request/BlockTimeOption.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client.request; 18 | 19 | import com.exonum.client.response.Block; 20 | 21 | /** 22 | * Request option for block commit time. 23 | * See {@link Block#getCommitTime()}. 24 | */ 25 | public enum BlockTimeOption { 26 | /** 27 | * Do not include block commit times in a response. 28 | */ 29 | NO_COMMIT_TIME, 30 | /** 31 | * Include block commit times in a response. 32 | */ 33 | INCLUDE_COMMIT_TIME 34 | } 35 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/java/com/exonum/client/response/TransactionStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client.response; 18 | 19 | import com.exonum.messages.core.runtime.Errors.ExecutionStatus; 20 | import com.google.gson.annotations.SerializedName; 21 | 22 | /** 23 | * Status of a particular transaction. 24 | */ 25 | public enum TransactionStatus { 26 | /** 27 | * Shows that transaction is in unconfirmed transaction pool currently. 28 | */ 29 | @SerializedName("in-pool") 30 | IN_POOL, 31 | /** 32 | * Shows that transaction is committed to the blockchain. 33 | * Please note that a committed transaction has not necessarily completed 34 | * successfully — use the {@linkplain ExecutionStatus execution result} 35 | * to check that. 36 | */ 37 | @SerializedName("committed") 38 | COMMITTED 39 | } 40 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/lombok/com/exonum/client/response/BlockResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client.response; 18 | 19 | import com.exonum.binding.common.hash.HashCode; 20 | import com.exonum.binding.common.message.TransactionMessage; 21 | import java.util.List; 22 | import lombok.Value; 23 | 24 | @Value 25 | public class BlockResponse { 26 | /** 27 | * Blockchain block. 28 | */ 29 | Block block; 30 | /** 31 | * Transaction hashes included at this block. 32 | * @see TransactionMessage#hash() 33 | */ 34 | List transactionHashes; 35 | } 36 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/lombok/com/exonum/client/response/ServiceInstanceInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client.response; 18 | 19 | import com.exonum.binding.common.message.TransactionMessage; 20 | import lombok.Value; 21 | 22 | @Value 23 | public class ServiceInstanceInfo { 24 | 25 | /** 26 | * Returns the name of the service instance. It serves as the primary identifier of this service 27 | * in most operations. It is assigned by the network administrators. 28 | */ 29 | String name; 30 | 31 | /** 32 | * Returns the numeric id of the service instance. Exonum assigns it to the service 33 | * on instantiation. It is mainly used to route the transaction messages belonging 34 | * to this instance. 35 | * 36 | * @see TransactionMessage#getServiceId() 37 | */ 38 | int id; 39 | } 40 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/lombok/com/exonum/client/response/ServiceInstanceState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client.response; 18 | 19 | import lombok.Value; 20 | 21 | @Value 22 | public class ServiceInstanceState { 23 | 24 | /** 25 | * Service instance spec - its name and id. 26 | */ 27 | ServiceInstanceInfo spec; 28 | } 29 | -------------------------------------------------------------------------------- /exonum-light-client/src/main/lombok/com/exonum/client/response/ServicesResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client.response; 18 | 19 | import java.util.List; 20 | import lombok.Value; 21 | 22 | @Value 23 | public class ServicesResponse { 24 | 25 | /** 26 | * List of started service instances. 27 | */ 28 | List services; 29 | } 30 | -------------------------------------------------------------------------------- /exonum-light-client/src/test/java/com/exonum/client/TestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Exonum Team 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.exonum.client; 18 | 19 | import static com.exonum.binding.common.crypto.CryptoFunctions.ed25519; 20 | 21 | import com.exonum.binding.common.message.TransactionMessage; 22 | import com.google.common.io.BaseEncoding; 23 | 24 | final class TestUtils { 25 | private static final BaseEncoding HEX_ENCODER = BaseEncoding.base16().lowerCase(); 26 | 27 | static TransactionMessage createTransactionMessage() { 28 | return TransactionMessage.builder() 29 | .serviceId(10) 30 | .transactionId(15) 31 | .payload(new byte[]{0x01, 0x02, 0x03}) 32 | .sign(ed25519().generateKeyPair()); 33 | } 34 | 35 | static String toHex(TransactionMessage message) { 36 | return HEX_ENCODER.encode(message.toBytes()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1 3 | } 4 | --------------------------------------------------------------------------------