From 74fd52a2f97488aebb05ae25560f8fd207f0950f Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Sat, 8 Jul 2023 16:05:04 -0700 Subject: [PATCH] SentToOwnersTestPlanSpec: simplify getStoProperty() * Make `numberOfTokens` effectively final * Use if/else for readability --- .../rpc/sto/SendToOwnersTestPlanSpec.groovy | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/omnij-rpc/src/integ/groovy/foundation/omni/test/rpc/sto/SendToOwnersTestPlanSpec.groovy b/omnij-rpc/src/integ/groovy/foundation/omni/test/rpc/sto/SendToOwnersTestPlanSpec.groovy index 6076ee92..abdf40a9 100644 --- a/omnij-rpc/src/integ/groovy/foundation/omni/test/rpc/sto/SendToOwnersTestPlanSpec.groovy +++ b/omnij-rpc/src/integ/groovy/foundation/omni/test/rpc/sto/SendToOwnersTestPlanSpec.groovy @@ -350,11 +350,9 @@ class SendToOwnersTestPlanSpec extends BaseRegTestSpec { def amountAvailable = OmniValue.of(new BigDecimal(data.AmountAvailable), propertyType) def ecosystem = Ecosystem.valueOf(Short.valueOf(data.Ecosystem)) def propertyName = new String(data.PropertyName) - def numberOfTokens = OmniValue.of(0, propertyType) - - if (amountAvailableOwners.size()) { - numberOfTokens += OmniValue.of((BigDecimal) amountAvailableOwners.sum(), propertyType) - } + def numberOfTokens = (amountAvailableOwners.size()) + ? OmniValue.of((BigDecimal) amountAvailableOwners.sum(), propertyType) + : OmniValue.of(0, propertyType) if (propertyName == "OMNI" || propertyName == "TOMNI") { if (numberOfTokens > 0) { @@ -363,22 +361,16 @@ class SendToOwnersTestPlanSpec extends BaseRegTestSpec { generateBlocks(1) } return CurrencyID.valueOf(propertyName) - } - - numberOfTokens += amountAvailable - -// if (propertyType == PropertyType.DIVISIBLE) { -// numberOfTokens = BTC.btcToSatoshis(numberOfTokens) -// } + } else { + def txid = createProperty(actorAddress, ecosystem, numberOfTokens + amountAvailable) + generateBlocks(1) - def txid = createProperty(actorAddress, ecosystem, numberOfTokens) - generateBlocks(1) - - def transaction = omniGetTransaction(txid) - assert transaction.valid - assert transaction.confirmations == 1 + def transaction = omniGetTransaction(txid) + assert transaction.valid + assert transaction.confirmations == 1 - return transaction.propertyId + return transaction.propertyId + } } /**