diff --git a/src/test/scala/tools/GenesisBlockGenerator.scala b/src/test/scala/tools/GenesisBlockGenerator.scala index 7920fb19d..cfa0c6b38 100644 --- a/src/test/scala/tools/GenesisBlockGenerator.scala +++ b/src/test/scala/tools/GenesisBlockGenerator.scala @@ -3,10 +3,8 @@ package tools import vsys.settings.{GenesisSettings, GenesisTransactionSettings} import vsys.blockchain.state.ByteStr import vsys.account.{Address, AddressScheme, PrivateKeyAccount} -import vsys.blockchain.block.Block -import vsys.blockchain.block.SposConsensusBlockData -import vsys.blockchain.transaction.{GenesisTransaction, Transaction} -import vsys.blockchain.transaction.{TransactionStatus, ProcessedTransaction} +import vsys.blockchain.block.{Block, SposConsensusBlockData} +import vsys.blockchain.transaction._ import vsys.blockchain.transaction.TransactionParser.SignatureLength import vsys.wallet.Wallet @@ -30,7 +28,7 @@ object GenesisBlockGenerator extends App { ) // add test use wallet address - val test_wallet_addresses = Array ( + val testWalletAddresses = Array ( "ATxpELPa3yhE5h4XELxtPrW9TfXPrmYE7ze", "ATtRykARbyJS1RwNsA6Rn1Um3S7FuVSovHK", "ATtchuwHVQmNTsRA8ba19juGK9m1gNsUS1V", @@ -44,7 +42,7 @@ object GenesisBlockGenerator extends App { ) def generateFullAddressInfo(n: Int) = { - println("n=" + n + ", address = " + test_wallet_addresses(n)) + println("n=" + n + ", address = " + testWalletAddresses(n)) val seed = ByteStr(Array.fill(32)((scala.util.Random.nextInt(256)).toByte)).toString val acc = Wallet.generateNewAccount(seed, 0) @@ -52,7 +50,7 @@ object GenesisBlockGenerator extends App { val publicKey = ByteStr(acc.publicKey) // change address value for testnet // val address = acc.toAddress - val address = Address.fromString(test_wallet_addresses(n)).right.get //ByteStr(Base58.decode(test_wallet_addresses(n)).get) + val address = Address.fromString(testWalletAddresses(n)).right.get //ByteStr(Base58.decode(test_wallet_addresses(n)).get) (seed, ByteStr(acc.seed), privateKey, publicKey, address) } @@ -71,7 +69,7 @@ object GenesisBlockGenerator extends App { val genesisTxs = accounts.map { case (n, (_, _, _, _, address)) => GenesisTransaction(address, distributions(accountsTotal)(n), n, timestamp, ByteStr.empty) } println(ByteStr(genesisTxs.head.bytes).base58) - // set the genesisblock's minting Balance to 0 + // set the genesisBlock's minting Balance to 0 val genesisBlock = Block.buildAndSign(1, timestamp, reference, SposConsensusBlockData(mt, 0L), genesisTxs.map{tx: Transaction => ProcessedTransaction(TransactionStatus.Success, tx.transactionFee, tx)}, genesisSigner) val signature = genesisBlock.signerData.signature diff --git a/src/test/scala/tools/MainnetGenesisBlockGenerator.scala b/src/test/scala/tools/MainnetGenesisBlockGenerator.scala index aeeab5652..47b4c1c64 100644 --- a/src/test/scala/tools/MainnetGenesisBlockGenerator.scala +++ b/src/test/scala/tools/MainnetGenesisBlockGenerator.scala @@ -3,10 +3,8 @@ package tools import vsys.settings.{GenesisSettings, GenesisTransactionSettings} import vsys.blockchain.state.ByteStr import vsys.account.{Address, AddressScheme, PrivateKeyAccount} -import vsys.blockchain.block.Block -import vsys.blockchain.block.SposConsensusBlockData -import vsys.blockchain.transaction.{GenesisTransaction, Transaction} -import vsys.blockchain.transaction.{TransactionStatus, ProcessedTransaction} +import vsys.blockchain.block.{Block, SposConsensusBlockData} +import vsys.blockchain.transaction._ import vsys.blockchain.transaction.TransactionParser.SignatureLength import vsys.settings.Constants._ @@ -36,7 +34,7 @@ object MainnetGenesisBlockGenerator extends App { ) // add wallet address - val wallet_addresses = Array ( + val walletAddresses = Array ( "ARKwwhnX2mk9V79kuvb3tEWVyri5Z2HFsPR", "AR2vo3jQjoyJLQysg99AYTR1SQ5mHqGhS1P", "AR8ejrETNWLaABp27fYEdh291MR1kDC92ue", @@ -70,7 +68,7 @@ object MainnetGenesisBlockGenerator extends App { "ARPnxBFbMzQQn4SncJ2WdH61ynqcPcninV4"//minters ) - val genesis_slots = Array ( + val genesisSlots = Array ( -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56 ) @@ -85,10 +83,10 @@ object MainnetGenesisBlockGenerator extends App { val mt = timestamp/ 4L * 4L / 1000000000L * 1000000000L - val accounts = wallet_addresses.indices.map(n => n -> Address.fromString(wallet_addresses(n)).right.get) - val genesisTxs = accounts.map { case (n, address) => GenesisTransaction(address, balanceDistributions(n), genesis_slots(n), timestamp, ByteStr.empty) } + val accounts = walletAddresses.indices.map(n => n -> Address.fromString(walletAddresses(n)).right.get) + val genesisTxs = accounts.map { case (n, address) => GenesisTransaction(address, balanceDistributions(n), genesisSlots(n), timestamp, ByteStr.empty) } - // set the genesisblock's minting Balance to 0 + // set the genesisBlock's minting Balance to 0 val genesisBlock = Block.buildAndSign(1, timestamp, reference, SposConsensusBlockData(mt, 0L), genesisTxs.map{tx: Transaction => ProcessedTransaction(TransactionStatus.Success, tx.transactionFee, tx)}, genesisSigner) val signature = genesisBlock.signerData.signature diff --git a/src/test/scala/vsys/blockchain/contract/OpcId.scala b/src/test/scala/vsys/blockchain/contract/OpcId.scala index 00ea5374e..ae6697619 100755 --- a/src/test/scala/vsys/blockchain/contract/OpcId.scala +++ b/src/test/scala/vsys/blockchain/contract/OpcId.scala @@ -2,13 +2,14 @@ package vsys.blockchain.contract import org.scalacheck.Gen import vsys.blockchain.state.opcdiffs._ +import OpcId._ trait OpcId { - import OpcId._ + def opcGen(id: Array[Byte]): Gen[Array[Byte]] = for { opc <- Gen.const(id) } yield opc - + // unused setting/gen val assertGteqZeroGen: Gen[Array[Byte]] = opcGen(opcAssertGteqZero) val assertLteqGen: Gen[Array[Byte]] = opcGen(opcAssertLteq) val assertLtInt64Gen: Gen[Array[Byte]] = opcGen(opcAssertLtInt64) @@ -20,21 +21,21 @@ trait OpcId { val loadSingerGen: Gen[Array[Byte]] = opcGen(opcLoadSigner) val loadCallerGen: Gen[Array[Byte]] = opcGen(opcLoadCaller) - val CDBVSetGen: Gen[Array[Byte]] = opcGen(opcCDBVSet) + val cdbvSetGen: Gen[Array[Byte]] = opcGen(opcCDBVSet) - val CDBVRGetGen: Gen[Array[Byte]] = opcGen(opcCDBVRGet) + val cdbvrGetGen: Gen[Array[Byte]] = opcGen(opcCDBVRGet) - val TDBNewTokenGen: Gen[Array[Byte]] = opcGen(opcTDBNewToken) - val TDBSplitGen: Gen[Array[Byte]] = opcGen(opcTDBSplit) + val tdbNewTokenGen: Gen[Array[Byte]] = opcGen(opcTDBNewToken) + val tdbSplitGen: Gen[Array[Byte]] = opcGen(opcTDBSplit) - val TDBROpcMaxGet: Gen[Array[Byte]] = opcGen(opcTDBROpcMax) - val TDBROpcTotalGen: Gen[Array[Byte]] = opcGen(opcTDBROpcTotal) + val tdbrOpcMaxGet: Gen[Array[Byte]] = opcGen(opcTDBROpcMax) + val tdbrOpcTotalGen: Gen[Array[Byte]] = opcGen(opcTDBROpcTotal) - val TDBADepositGen: Gen[Array[Byte]] = opcGen(opcTDBADeposit) - val TDBAWithdrawGen: Gen[Array[Byte]] = opcGen(opcTDBAWithdraw) - val TDBATransferGen: Gen[Array[Byte]] = opcGen(opcTDBATransfer) + val rdbaDepositGen: Gen[Array[Byte]] = opcGen(opcTDBADeposit) + val tdbaWithdrawGen: Gen[Array[Byte]] = opcGen(opcTDBAWithdraw) + val tbdaTransferGen: Gen[Array[Byte]] = opcGen(opcTDBATransfer) - val TDBARBalanceGen: Gen[Array[Byte]] = opcGen(opcTDBARBalance) + val tdbarBalanceGen: Gen[Array[Byte]] = opcGen(opcTDBARBalance) } object OpcId { diff --git a/src/test/scala/vsys/blockchain/state/diffs/SPOSTransactionDiffTest.scala b/src/test/scala/vsys/blockchain/state/diffs/SPOSTransactionDiffTest.scala index 858c149bb..8ef43e0bd 100644 --- a/src/test/scala/vsys/blockchain/state/diffs/SPOSTransactionDiffTest.scala +++ b/src/test/scala/vsys/blockchain/state/diffs/SPOSTransactionDiffTest.scala @@ -16,8 +16,6 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato private implicit def noShrink[A]: Shrink[A] = Shrink(_ => Stream.empty) - val ENOUGH_AMT: Long = Long.MaxValue / 3 - val preconditionsAndContend: Gen[(GenesisTransaction, ContendSlotsTransaction, ContendSlotsTransaction, ContendSlotsTransaction, ContendSlotsTransaction, Long)] = for { master <- accountGen ts <- positiveIntGen @@ -31,13 +29,15 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato } yield (genesis, contend, contendMultiSlots, contendInvalidId1, contendInvalidId2, contend.transactionFee) property("contend transaction doesn't break invariant") { - forAll(preconditionsAndContend) { case (genesis, contend, _, _, _, feeContend) => + forAll(preconditionsAndContend) { case (genesis, contend: ContendSlotsTransaction, _, _, _, feeContend) => assertDiffAndState(Seq(TestBlock.create(Seq(genesis))), TestBlock.create(Seq(contend))) { (blockDiff, newState) => val totalPortfolioDiff: Portfolio = Monoid.combineAll(blockDiff.txsDiff.portfolios.values) totalPortfolioDiff.balance shouldBe -feeContend totalPortfolioDiff.effectiveBalance shouldBe -feeContend - val sender = EllipticCurve25519Proof.fromBytes(contend.proofs.proofs.head.bytes.arr).toOption.get.publicKey - newState.accountTransactionIds(sender, 2, 0)._2.size shouldBe 2 // genesis and payment + val proof = contend.proofs.firstCurveProof.explicitGet() + val sender = EllipticCurve25519Proof.fromBytes(proof.bytes.arr).explicitGet.publicKey + val (_, txList) = newState.accountTransactionIds(sender, 2, 0) + txList.size shouldBe 2 // genesis and payment } } } @@ -126,14 +126,16 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato property("release transaction doesn't break invariant") { forAll(preconditionsAndRelease) { case (genesis0, genesis1, genesis2, genesis3, genesis4, genesis5, genesis6, - genesis7, genesis8, genesis9, genesis10, release1, _, _, _, f1) => + genesis7, genesis8, genesis9, genesis10, release1: ReleaseSlotsTransaction, _, _, _, f1) => assertDiffAndState(Seq(TestBlock.create(Seq(genesis0, genesis1, genesis2, genesis3, genesis4, genesis5, genesis6, genesis7, genesis8, genesis9, genesis10))), TestBlock.create(Seq(release1))) { (blockDiff, newState) => val totalPortfolioDiff: Portfolio = Monoid.combineAll(blockDiff.txsDiff.portfolios.values) totalPortfolioDiff.balance shouldBe - f1 totalPortfolioDiff.effectiveBalance shouldBe -f1 - val sender = EllipticCurve25519Proof.fromBytes(release1.proofs.proofs.head.bytes.arr).toOption.get.publicKey - newState.accountTransactionIds(sender, 10, 0)._2.size shouldBe 2 // genesis and release + val proof = release1.proofs.firstCurveProof.explicitGet() + val sender = EllipticCurve25519Proof.fromBytes(proof.bytes.arr).explicitGet.publicKey + val (_, txList) = newState.accountTransactionIds(sender, 10, 0) + txList.size shouldBe 2 // genesis and release } } } @@ -179,7 +181,7 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato slotId <- slotidGen genesis: GenesisTransaction = GenesisTransaction.create(master, ENOUGH_AMT, -1, ts).explicitGet() contendTmp: ContendSlotsTransaction <- contendGeneratorP(master, slotId) - proof = contendTmp.proofs.proofs.head + proof = contendTmp.proofs.firstCurveProof.explicitGet proofs = Proofs(List(proof, proof)) // two proofs case contend = contendTmp.copy(proofs = proofs) } yield (genesis, contend) @@ -198,7 +200,7 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato genesis: GenesisTransaction = GenesisTransaction.create(master, ENOUGH_AMT, -1, ts).explicitGet() contend: ContendSlotsTransaction <- contendGeneratorP(master, 0) releaseTmp: ReleaseSlotsTransaction <- releaseGeneratorP(master, 0) - proof = releaseTmp.proofs.proofs.head + proof = releaseTmp.proofs.firstCurveProof.explicitGet proofs = Proofs(List(proof, proof)) // two proofs case release = releaseTmp.copy(proofs = proofs) } yield (genesis, contend, release) diff --git a/src/test/scala/vsys/blockchain/state/reader/StateReaderTransactionQueryTest.scala b/src/test/scala/vsys/blockchain/state/reader/StateReaderTransactionQueryTest.scala index aeaed6782..c48fecf48 100644 --- a/src/test/scala/vsys/blockchain/state/reader/StateReaderTransactionQueryTest.scala +++ b/src/test/scala/vsys/blockchain/state/reader/StateReaderTransactionQueryTest.scala @@ -7,10 +7,9 @@ import org.scalatest.prop.{GeneratorDrivenPropertyChecks, PropertyChecks} import org.scalatest.{Matchers, PropSpec} import vsys.blockchain.block.TestBlock import vsys.blockchain.state.EitherExt2 -import vsys.blockchain.transaction.{GenesisTransaction, PaymentTransaction, Transaction} +import vsys.blockchain.transaction._ import vsys.blockchain.transaction.lease.{LeaseCancelTransaction, LeaseTransaction} import vsys.blockchain.transaction.TransactionParser.TransactionType -import vsys.blockchain.transaction.{ProcessedTransaction, TransactionGen, TransactionStatus} class StateReaderTransactionQueryTest extends PropSpec with PropertyChecks with GeneratorDrivenPropertyChecks with Matchers with TransactionGen { diff --git a/vsys-mainnet.conf b/vsys-mainnet.conf index fc8578039..9f2e41d8c 100644 --- a/vsys-mainnet.conf +++ b/vsys-mainnet.conf @@ -9,7 +9,7 @@ vsys { # P2P Network settings network { - known-peers = ["13.55.174.115:9921","52.30.23.41:9921","13.113.98.91:9921","3.121.94.10:9921"] + known-peers = ["13.55.174.115:9921","13.52.40.227:9921","13.113.98.91:9921","3.121.94.10:9921"] black-list-residence-time = 30s diff --git a/vsys-testnet.conf b/vsys-testnet.conf index 481641107..07d450a91 100644 --- a/vsys-testnet.conf +++ b/vsys-testnet.conf @@ -3,7 +3,7 @@ vsys { #data-directory = 'your local path' logging-level = DEBUG network { - known-peers = ["54.193.47.112:9923","13.57.25.133:9923","18.218.106.1:9923","3.17.78.253:9923","34.222.191.174:9923"] + known-peers = ["54.193.47.112:9923","13.56.200.72:9923","18.218.106.1:9923","3.17.78.253:9923","34.222.191.174:9923"] black-list-residence-time = 30s peers-broadcast-interval = 5s connection-timeout = 30s