diff --git a/samples/contract-samples/pom.xml b/samples/contract-samples/pom.xml index f542780b..9429edcc 100644 --- a/samples/contract-samples/pom.xml +++ b/samples/contract-samples/pom.xml @@ -17,14 +17,12 @@ com.jd.blockchain ledger-model - ${project.version} provided com.jd.blockchain crypto-framework - ${project.version} provided diff --git a/samples/pom.xml b/samples/pom.xml index 26a33f96..aa28bdad 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -24,5 +24,27 @@ contract-samples + + + + + com.jd.blockchain + sdk-client + ${framework.version} + + + com.jd.blockchain + ledger-model + ${framework.version} + + + com.jd.blockchain + crypto-framework + ${framework.version} + + + + + diff --git a/samples/sdk-samples/pom.xml b/samples/sdk-samples/pom.xml index 178d8d23..e6eba29d 100644 --- a/samples/sdk-samples/pom.xml +++ b/samples/sdk-samples/pom.xml @@ -13,12 +13,10 @@ com.jd.blockchain sdk-client - ${project.version} com.jd.blockchain ledger-model - ${project.version} com.jd.blockchain diff --git a/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Check_Demo.java b/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Check_Demo.java index 7d521776..c99b9a6b 100644 --- a/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Check_Demo.java +++ b/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Check_Demo.java @@ -1,14 +1,17 @@ package com.jd.blockchain.sdk.samples; -import com.jd.blockchain.contract.TransferContract; -import com.jd.blockchain.ledger.*; +import static com.jd.blockchain.sdk.samples.SDKDemo_Constant.readChainCodes; +import static com.jd.blockchain.transaction.ContractReturnValue.decode; + +import com.jd.blockchain.ledger.BlockchainKeyGenerator; +import com.jd.blockchain.ledger.BlockchainKeypair; +import com.jd.blockchain.ledger.PreparedTransaction; +import com.jd.blockchain.ledger.TransactionResponse; +import com.jd.blockchain.ledger.TransactionTemplate; import com.jd.blockchain.transaction.GenericValueHolder; import com.jd.blockchain.utils.Bytes; import com.jd.chain.contracts.ContractTestInf; -import static com.jd.blockchain.sdk.samples.SDKDemo_Constant.readChainCodes; -import static com.jd.blockchain.transaction.ContractReturnValue.decode; - public class SDK_Contract_Check_Demo extends SDK_Base_Demo { public static void main(String[] args) { diff --git a/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Demo.java b/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Demo.java index caae0d6d..0574cf51 100644 --- a/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Demo.java +++ b/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Demo.java @@ -6,12 +6,12 @@ import static com.jd.blockchain.transaction.ContractReturnValue.decode; import com.jd.blockchain.contract.TransferContract; import com.jd.blockchain.ledger.BlockchainKeyGenerator; import com.jd.blockchain.ledger.BlockchainKeypair; -import com.jd.blockchain.ledger.TypedKVEntry; import com.jd.blockchain.ledger.PreparedTransaction; import com.jd.blockchain.ledger.TransactionResponse; import com.jd.blockchain.ledger.TransactionTemplate; -import com.jd.blockchain.transaction.LongValueHolder; +import com.jd.blockchain.ledger.TypedKVEntry; import com.jd.blockchain.transaction.GenericValueHolder; +import com.jd.blockchain.transaction.LongValueHolder; import com.jd.blockchain.utils.Bytes; public class SDK_Contract_Demo extends SDK_Base_Demo { diff --git a/test/pom.xml b/test/pom.xml index 5219328f..4928243f 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -4,29 +4,114 @@ 4.0.0 com.jd.blockchain - jdchain-root - 1.1.2.RELEASE + jdchain-core + 1.2.0-SNAPSHOT + ../core + + + com.jd.blockchain test + 1.2.0-SNAPSHOT pom + + 1.2.0-SNAPSHOT + + + ../core test-consensus-client test-consensus-node test-ledger + test-contract test-integration - - - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - true - - - - + + + + + com.jd.blockchain + consensus-bftsmart + ${core.version} + + + com.jd.blockchain + consensus-mq + ${core.version} + + + + com.jd.blockchain + contract-jvm + ${core.version} + + + com.jd.blockchain + contract-maven-plugin + ${core.version} + + + + com.jd.blockchain + crypto-adv + ${core.version} + + + com.jd.blockchain + crypto-pki + ${core.version} + + + + com.jd.blockchain + gateway + ${core.version} + + + + com.jd.blockchain + peer + ${core.version} + + + + com.jd.blockchain + ledger-database + ${core.version} + + + + com.jd.blockchain + runtime-context + ${core.version} + + + com.jd.blockchain + runtime-modular + ${core.version} + + + com.jd.blockchain + runtime-modular-booter + ${core.version} + + + + com.jd.blockchain + storage-redis + ${core.version} + + + com.jd.blockchain + storage-rocksdb + ${core.version} + + + + + + + \ No newline at end of file diff --git a/test/test-consensus-client/pom.xml b/test/test-consensus-client/pom.xml index 78bc7c75..241f946e 100644 --- a/test/test-consensus-client/pom.xml +++ b/test/test-consensus-client/pom.xml @@ -5,7 +5,7 @@ com.jd.blockchain test - 1.1.2.RELEASE + 1.2.0-SNAPSHOT test-consensus-client @@ -29,25 +29,19 @@ com.jd.blockchain consensus-bftsmart - ${project.version} + ${core.version} - + org.springframework.boot spring-boot-configuration-processor true - + diff --git a/test/test-consensus-node/pom.xml b/test/test-consensus-node/pom.xml index af98ce14..5f60b7ed 100644 --- a/test/test-consensus-node/pom.xml +++ b/test/test-consensus-node/pom.xml @@ -5,9 +5,10 @@ com.jd.blockchain test - 1.1.2.RELEASE + 1.2.0-SNAPSHOT test-consensus-node + org.springframework.boot @@ -28,17 +29,12 @@ com.jd.blockchain peer - ${project.version} + ${core.version} - - - - - com.jd.blockchain consensus-bftsmart - 1.1.2.RELEASE + ${core.version} org.springframework.boot diff --git a/test/test-contract/pom.xml b/test/test-contract/pom.xml index a9c59ddf..ac5e45d5 100644 --- a/test/test-contract/pom.xml +++ b/test/test-contract/pom.xml @@ -5,7 +5,7 @@ com.jd.blockchain test - 1.0.1.RELEASE + 1.2.0-SNAPSHOT test-contract @@ -13,22 +13,22 @@ com.jd.blockchain contract-jvm - ${project.version} + ${core.version} com.jd.blockchain - ledger-core - ${project.version} + ledger-database + ${core.version} com.jd.blockchain storage-rocksdb - ${project.version} + ${core.version} - + \ No newline at end of file diff --git a/test/test-integration/pom.xml b/test/test-integration/pom.xml index 4f63af4d..07fc7801 100644 --- a/test/test-integration/pom.xml +++ b/test/test-integration/pom.xml @@ -5,60 +5,61 @@ com.jd.blockchain test - 1.1.2.RELEASE + 1.2.0-SNAPSHOT test-integration + + org.mockito + mockito-core + compile + com.jd.blockchain peer - ${project.version} + ${core.version} com.jd.blockchain storage-rocksdb - ${project.version} + ${core.version} com.jd.blockchain storage-redis - ${project.version} + ${core.version} com.jd.blockchain gateway - ${project.version} + ${core.version} com.jd.blockchain tools-initializer - ${project.version} + ${core.version} com.jd.blockchain sdk-client - ${project.version} + ${framework.version} - - com.jd.blockchain - contract-samples - ${project.version} - - - io.nats - jnats + com.jd.blockchain + crypto-classic + ${framework.version} + - com.jd.blockchain - crypto-classic - ${project.version} + io.nats + jnats + diff --git a/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java b/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java index 05824443..16fae5c0 100644 --- a/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java +++ b/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java @@ -8,6 +8,7 @@ import java.util.Properties; import java.util.Random; import java.util.concurrent.CountDownLatch; +import org.mockito.Mockito; import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.consensus.ConsensusProvider; diff --git a/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java b/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java index 37c792f2..d2ec4e1e 100644 --- a/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java +++ b/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java @@ -31,7 +31,7 @@ import org.apache.commons.io.FileUtils; import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.contract.ReadContract; +//import com.jd.blockchain.contract.ReadContract; import com.jd.blockchain.crypto.AddressEncoding; import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; diff --git a/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ReadContract.java b/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ReadContract.java new file mode 100644 index 00000000..1c22a57c --- /dev/null +++ b/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ReadContract.java @@ -0,0 +1,17 @@ +package test.com.jd.blockchain.intgr; + +import com.jd.blockchain.contract.Contract; +import com.jd.blockchain.contract.ContractEvent; + +@Contract +public interface ReadContract { + + @ContractEvent(name = "read-key") + String read(String address, String key); + + @ContractEvent(name = "version-key") + Long readVersion(String address, String key); + + int test(); +} + diff --git a/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ReadContractImpl.java b/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ReadContractImpl.java new file mode 100644 index 00000000..87380e3b --- /dev/null +++ b/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ReadContractImpl.java @@ -0,0 +1,54 @@ +package test.com.jd.blockchain.intgr; + +import com.jd.blockchain.contract.Contract; +import com.jd.blockchain.contract.ContractEvent; +import com.jd.blockchain.contract.ContractEventContext; +import com.jd.blockchain.contract.EventProcessingAware; +import com.jd.blockchain.crypto.HashDigest; +import com.jd.blockchain.ledger.TypedKVEntry; + +@Contract +public class ReadContractImpl implements EventProcessingAware, ReadContract { + + private ContractEventContext eventContext; + + private HashDigest ledgerHash; + + @Override + public void beforeEvent(ContractEventContext eventContext) { + this.eventContext = eventContext; + this.ledgerHash = eventContext.getCurrentLedgerHash(); + } + + @Override + public void postEvent(ContractEventContext eventContext, Exception error) { + + } + + @Override + @ContractEvent(name = "read-key") + public String read(String address, String key) { + TypedKVEntry[] kvDataEntries = eventContext.getLedger().getDataEntries(ledgerHash, address, key); + + if (kvDataEntries != null && kvDataEntries.length == 1) { + return kvDataEntries[0].getValue().toString(); + } + return null; + } + + @Override + @ContractEvent(name = "version-key") + public Long readVersion(String address, String key) { + TypedKVEntry[] kvDataEntries = eventContext.getLedger().getDataEntries(ledgerHash, address, key); + + if (kvDataEntries != null && kvDataEntries.length == 1) { + return kvDataEntries[0].getVersion(); + } + return -1L; + } + + @Override + public int test() { + return 0; + } +} diff --git a/test/test-ledger/pom.xml b/test/test-ledger/pom.xml index 5c001f85..f59f96e1 100644 --- a/test/test-ledger/pom.xml +++ b/test/test-ledger/pom.xml @@ -5,7 +5,7 @@ com.jd.blockchain test - 1.1.2.RELEASE + 1.2.0-SNAPSHOT test-ledger @@ -13,27 +13,27 @@ com.jd.blockchain tools-initializer - ${project.version} + ${core.version} com.jd.blockchain - ledger-core - ${project.version} + ledger-database + ${core.version} com.jd.blockchain storage-redis - ${project.version} + ${core.version} com.jd.blockchain storage-rocksdb - ${project.version} + ${core.version} com.jd.blockchain crypto-classic - ${project.version} + ${framework.version}