Skip to content
Snippets Groups Projects
Unverified Commit d7a99aa0 authored by Luca Moser's avatar Luca Moser
Browse files

fixes some asserts

parent a8688f46
Branches
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/wallet" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/wallet"
"github.com/iotaledger/goshimmer/plugins/webapi/value/utils"
"github.com/iotaledger/goshimmer/tools/integration-tests/tester/tests" "github.com/iotaledger/goshimmer/tools/integration-tests/tester/tests"
"github.com/mr-tron/base58/base58" "github.com/mr-tron/base58/base58"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
...@@ -47,12 +48,13 @@ func TestConsensusNoConflicts(t *testing.T) { ...@@ -47,12 +48,13 @@ func TestConsensusNoConflicts(t *testing.T) {
}), }),
) )
tx = tx.Sign(signaturescheme.ED25519(*genesisWallet.Seed().KeyPair(0))) tx = tx.Sign(signaturescheme.ED25519(*genesisWallet.Seed().KeyPair(0)))
utilsTx := utils.ParseTransaction(tx)
txID, err := n.Peers()[0].SendTransaction(tx.Bytes()) txID, err := n.Peers()[0].SendTransaction(tx.Bytes())
require.NoError(t, err) require.NoError(t, err)
// wait for the transaction to be propagated through the network // wait for the transaction to be propagated through the network
time.Sleep(10 * time.Second) time.Sleep(20 * time.Second)
// check that each node has the same perception // check that each node has the same perception
for _, p := range n.Peers() { for _, p := range n.Peers() {
...@@ -60,20 +62,22 @@ func TestConsensusNoConflicts(t *testing.T) { ...@@ -60,20 +62,22 @@ func TestConsensusNoConflicts(t *testing.T) {
res, err := p.GetTransactionByID(txID) res, err := p.GetTransactionByID(txID)
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, res.Error, 0, "there shouldn't be any error from submitting the valid transaction") assert.Len(t, res.Error, 0, "there shouldn't be any error from submitting the valid transaction")
assert.Len(t, res.Transaction.Inputs, 1) assert.EqualValues(t, utilsTx.Inputs, res.Transaction.Inputs)
assert.Equal(t, genesisOutputID.String(), res.Transaction.Inputs[0]) assert.EqualValues(t, utilsTx.Outputs, res.Transaction.Outputs)
assert.EqualValues(t, utilsTx.Signature, res.Transaction.Signature)
// check that genesis UTXO is spent // check that genesis UTXO is spent
utxos, err := p.GetUnspentOutputs([]string{genesisAddr.String()}) utxos, err := p.GetUnspentOutputs([]string{genesisAddr.String()})
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, utxos.Error, 0, "there shouldn't be any error from querying UTXOs")
assert.Len(t, utxos.UnspentOutputs, 0, "genesis address should not have any UTXOs") assert.Len(t, utxos.UnspentOutputs, 0, "genesis address should not have any UTXOs")
// check UTXOs // check UTXOs
utxos, err = p.GetUnspentOutputs([]string{addr1.String(), addr2.String()}) utxos, err = p.GetUnspentOutputs([]string{addr1.String(), addr2.String()})
assert.Len(t, utxos.UnspentOutputs, 2, "addresses should have UTXOs") assert.Len(t, utxos.UnspentOutputs, 2, "addresses should have UTXOs")
assert.Equal(t, addr1.String(), utxos.UnspentOutputs[0].Address) assert.Equal(t, addr1.String(), utxos.UnspentOutputs[0].Address)
assert.Equal(t, deposit, utxos.UnspentOutputs[0].OutputIDs[0].Balances[0].Value) assert.EqualValues(t, deposit, utxos.UnspentOutputs[0].OutputIDs[0].Balances[0].Value)
assert.Equal(t, addr2.String(), utxos.UnspentOutputs[1].Address) assert.Equal(t, addr2.String(), utxos.UnspentOutputs[1].Address)
assert.Equal(t, deposit, utxos.UnspentOutputs[1].OutputIDs[0].Balances[0].Value) assert.EqualValues(t, deposit, utxos.UnspentOutputs[1].OutputIDs[0].Balances[0].Value)
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment