Created
August 16, 2018 12:26
-
-
Save Alexey-N-Chernyshov/696c8edea7106c4ac0990973a114aa67 to your computer and use it in GitHub Desktop.
Quorum example in Iroha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun testQuorum() { | |
var keypair1 = ModelCrypto().generateKeypair() | |
var keypair2 = ModelCrypto().generateKeypair() | |
var txBuilder = ModelUtil.getModelTransactionBuilder() | |
var tx = txBuilder | |
.createdTime(ModelUtil.getCurrentTime()) | |
.creatorAccountId("test@notary") | |
.createAccount("multisig", "notary", keypair1.publicKey()) | |
.appendRole("multisig@notary", "tester") | |
.build() | |
irohaConsumer.sendAndCheck(tx) | |
txBuilder = ModelUtil.getModelTransactionBuilder() | |
tx = txBuilder | |
.createdTime(ModelUtil.getCurrentTime()) | |
.creatorAccountId("multisig@notary") | |
.addSignatory("multisig@notary", keypair2.publicKey()) | |
.setAccountQuorum("multisig@notary", 2) | |
.build() | |
var hash = tx.hash() | |
ModelUtil.prepareTransaction(tx, keypair1) | |
.flatMap { IrohaNetworkImpl(testConfig.iroha.hostname, testConfig.iroha.port).sendAndCheck(it, hash) } | |
val time = ModelUtil.getCurrentTime() | |
txBuilder = ModelUtil.getModelTransactionBuilder() | |
tx = txBuilder | |
.createdTime(time) | |
.creatorAccountId("multisig@notary") | |
.setAccountDetail("multisig@notary", "key", "value") | |
.build() | |
hash = tx.hash() | |
ModelUtil.prepareTransaction(tx, keypair1) | |
.flatMap { IrohaNetworkImpl(testConfig.iroha.hostname, testConfig.iroha.port).sendAndCheck(it, hash) } | |
println("wait") | |
Thread.sleep(5_000) | |
println("2nd send: $hash") | |
ModelUtil.prepareTransaction(tx, keypair2) | |
.flatMap { IrohaNetworkImpl(testConfig.iroha.hostname, testConfig.iroha.port).sendAndCheck(it, hash) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment