Skip to content

Commit

Permalink
chore: improve cucumber tests to wait for broadcast (#3461)
Browse files Browse the repository at this point in the history
Description
---
Changed connect node to wait for both nodes to listening
Changed send transactions to wait for broadcast state. 
Removed some flaky and long-running tags.

Motivation and Context
---
This will test to run faster as more stable. Current SHA3 miner mines too fast for the wallets to finish sending. This PR market wait for the transaction to be broadcast before continuing. 
This makes the connect node to await listing state of both nodes to avoid using waits.

How Has This Been Tested?
---
Manual test of tests
  • Loading branch information
SWvheerden authored Oct 21, 2021
1 parent a72f42f commit 4bc7c2a
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 106 deletions.
2 changes: 1 addition & 1 deletion integration_tests/features/Mempool.feature
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Feature: Mempool
Then NODE_B has TXB in MEMPOOL state
When I mine 1 blocks on NODE_A
When I mine 1 blocks on NODE_B
And I connect node NODE_A to node NODE_B and wait 1 seconds
And I connect node NODE_A to node NODE_B
Then all nodes are at height 12
Then NODE_A has TXA in NOT_STORED state
Then NODE_A has TXB in MINED state
Expand Down
30 changes: 14 additions & 16 deletions integration_tests/features/Reorgs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ Feature: Reorgs
#
# Connect Chain 1a and 1b
#
And I connect node NODE_A1 to node NODE_A3 and wait 1 seconds
And I connect node NODE_A2 to node NODE_A4 and wait 1 seconds
And I connect node SEED_A1 to node SEED_A2 and wait <SYNC_TIME> seconds
And I connect node NODE_A1 to node NODE_A3
And I connect node NODE_A2 to node NODE_A4
And I connect node SEED_A1 to node SEED_A2
Then node SEED_A1 is in state LISTENING
Then node SEED_A2 is in state LISTENING
When I mine 10 blocks on SEED_A1
Expand Down Expand Up @@ -194,9 +194,9 @@ Feature: Reorgs
#
# Connect Chain 2a and 2b
#
And I connect node NODE_B1 to node NODE_B3 and wait 1 seconds
And I connect node NODE_B2 to node NODE_B4 and wait 1 seconds
And I connect node SEED_B1 to node SEED_B2 and wait <SYNC_TIME> seconds
And I connect node NODE_B1 to node NODE_B3
And I connect node NODE_B2 to node NODE_B4
And I connect node SEED_B1 to node SEED_B2
Then node SEED_B2 is in state LISTENING
Then node SEED_B1 is in state LISTENING
When I mine 10 blocks on SEED_B1
Expand All @@ -208,23 +208,21 @@ Feature: Reorgs
#
# Connect Chain 1 and 2
#
And I connect node NODE_A1 to node NODE_B1 and wait 1 seconds
And I connect node NODE_A3 to node NODE_B3 and wait 1 seconds
And I connect node SEED_A1 to node SEED_B1 and wait <SYNC_TIME> seconds
Then node SEED_A1 is in state LISTENING
Then node SEED_B1 is in state LISTENING
And I connect node NODE_A1 to node NODE_B1
And I connect node NODE_A3 to node NODE_B3
And I connect node SEED_A1 to node SEED_B1
When I mine 10 blocks on SEED_A1
Then all nodes are on the same chain tip

Examples:
| X1 | Y1 | X2 | Y2 | SYNC_TIME |
| 5 | 10 | 15 | 20 | 1 |
| X1 | Y1 | X2 | Y2 |
| 5 | 10 | 15 | 20 |

@long-running
Examples:
| X1 | Y1 | X2 | Y2 | SYNC_TIME |
| 100 | 125 | 150 | 175 | 1 |
| 1010 | 1110 | 1210 | 1310 | 1 |
| X1 | Y1 | X2 | Y2 |
| 100 | 125 | 150 | 175 |
| 1010 | 1110 | 1210 | 1310 |

@reorg
Scenario: Full block sync with small reorg
Expand Down
7 changes: 3 additions & 4 deletions integration_tests/features/StressTest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ Feature: Stress Test
And I have stress-test wallet WALLET_A connected to the seed node NODE1 with broadcast monitoring timeout <MonitoringTimeout>
And I have mining node MINER connected to base node NODE1 and wallet WALLET_A
# We mine some blocks before starting the other nodes to avoid a spinning sync state when all the nodes are at height 0
When mining node MINER mines 6 blocks
And I have a seed node NODE2
And I have <NumNodes> base nodes connected to all seed nodes
And I have stress-test wallet WALLET_B connected to the seed node NODE2 with broadcast monitoring timeout <MonitoringTimeout>
When mining node MINER mines 6 blocks
# There need to be at least as many mature coinbase UTXOs in the wallet coin splits required for the number of transactions
When mining node MINER mines <NumCoinsplitsNeeded> blocks
Then all nodes are on the same chain tip
When I wait for wallet WALLET_A to have at least 5100000000 uT

Then I coin split tari in wallet WALLET_A to produce <NumTransactions> UTXOs of 5000 uT each with fee_per_gram 4 uT
When I wait 30 seconds
Then I coin split tari in wallet WALLET_A to produce <NumTransactions> UTXOs of 5000 uT each with fee_per_gram 20 uT
When mining node MINER mines 3 blocks
When mining node MINER mines <NumCoinsplitsNeeded> blocks
Then all nodes are on the same chain tip
Expand All @@ -32,7 +31,7 @@ Feature: Stress Test
# Then wallet WALLET_B detects all transactions as Mined_Confirmed
Then while mining via node NODE1 all transactions in wallet WALLET_B are found to be Mined_Confirmed

@flaky @current
@flaky
Examples:
| NumTransactions | NumCoinsplitsNeeded | NumNodes | MonitoringTimeout |
| 10 | 1 | 3 | 10 |
Expand Down
4 changes: 1 addition & 3 deletions integration_tests/features/Sync.feature
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Feature: Block Sync
Then node PNODE2 is at height 40
When I start base node NODE1
# We need for node to boot up and supply node 2 with blocks
And I connect node NODE2 to node NODE1 and wait 1 seconds
And I connect node NODE2 to node NODE1
# NODE2 may initially try to sync from PNODE1 and PNODE2, then eventually try to sync from NODE1; mining blocks
# on NODE1 will make this test less flaky and force NODE2 to sync from NODE1 much quicker
When I mine 10 blocks on NODE1
Expand All @@ -100,8 +100,6 @@ Feature: Block Sync
When I start base node SYNCER
# Try to mine much faster than block sync, but still producing a lower accumulated difficulty
And mining node MINER2 mines <Y1> blocks with min difficulty 1 and max difficulty 10
# Allow reorg to filter through
Then node SYNCER is in state LISTENING
Then node SYNCER is at the same height as node SEED
@critical
Examples:
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/features/WalletFFI.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Feature: Wallet FFI
And mining node MINER mines 10 blocks
Then I wait for wallet SENDER to have at least 1000000 uT
And I have a ffi wallet FFI_WALLET connected to base node BASE
And I send 2000000 uT from wallet SENDER to wallet FFI_WALLET at fee 20
And I send 2000000 uT without waiting for broadcast from wallet SENDER to wallet FFI_WALLET at fee 20
And wallet SENDER detects all transactions are at least Broadcast
And mining node MINER mines 10 blocks
Then I wait for ffi wallet FFI_WALLET to have at least 1000000 uT
Expand Down Expand Up @@ -107,7 +107,7 @@ Feature: Wallet FFI
And I have a ffi wallet FFI_WALLET connected to base node BASE
And I stop ffi wallet FFI_WALLET
And I wait 10 seconds
And I send 2000000 uT from wallet SENDER to wallet FFI_WALLET at fee 20
And I send 2000000 uT without waiting for broadcast from wallet SENDER to wallet FFI_WALLET at fee 20
And I wait 5 seconds
# Broken step with reason base node is not persisted
# Log:
Expand Down
6 changes: 2 additions & 4 deletions integration_tests/features/WalletMonitoring.feature
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ Feature: Wallet Monitoring
Then node NODE_A1 is at height 10
Then wallet WALLET_A1 detects at least 7 coinbase transactions as Mined_Confirmed
# Use 7 of the 10 coinbase UTXOs in transactions (others require 3 confirmations)
And I multi-send 7 transactions of 1000000 uT from wallet WALLET_A1 to wallet WALLET_A2 at fee 20
Then wallet WALLET_A1 detects all transactions are at least Broadcast
And I multi-send 7 transactions of 1000000 uT from wallet WALLET_A1 to wallet WALLET_A2 at fee 100
When I mine 100 blocks on SEED_A
Then node SEED_A is at height 110
Then node NODE_A1 is at height 110
Expand All @@ -88,8 +87,7 @@ Feature: Wallet Monitoring
Then node NODE_B1 is at height 10
Then wallet WALLET_B1 detects at least 7 coinbase transactions as Mined_Confirmed
# Use 7 of the 10 coinbase UTXOs in transactions (others require 3 confirmations)
And I multi-send 7 transactions of 1000000 uT from wallet WALLET_B1 to wallet WALLET_B2 at fee 20
Then wallet WALLET_B1 detects all transactions are at least Broadcast
And I multi-send 7 transactions of 1000000 uT from wallet WALLET_B1 to wallet WALLET_B2 at fee 100
When I mine 100 blocks on SEED_B
Then node SEED_B is at height 110
Then node NODE_B1 is at height 110
Expand Down
3 changes: 1 addition & 2 deletions integration_tests/features/WalletRecovery.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Feature: Wallet Recovery
When I recover wallet WALLET_A into wallet WALLET_B connected to all seed nodes
Then wallet WALLET_A and wallet WALLET_B have the same balance
And I have wallet WALLET_C connected to all seed nodes
And I send 100000 uT from wallet WALLET_B to wallet WALLET_C at fee 20
Then wallet WALLET_B detects all transactions are at least Broadcast
And I send 100000 uT from wallet WALLET_B to wallet WALLET_C at fee 100
When I mine 5 blocks on NODE
Then all nodes are at height 20
Then I wait for wallet WALLET_C to have at least 100000 uT
Expand Down
5 changes: 1 addition & 4 deletions integration_tests/features/WalletRoutingMechanism.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ Scenario Outline: Wallets transacting via specified routing mechanism only
When I wait 1 seconds
When I wait for wallet WALLET_A to have at least 100000000 uT
#When I print the world
And I multi-send 1000000 uT from wallet WALLET_A to all wallets at fee 20
Then all wallets detect all transactions are at least Pending
Then all wallets detect all transactions are at least Completed
Then all wallets detect all transactions are at least Broadcast
And I multi-send 1000000 uT from wallet WALLET_A to all wallets at fee 100
# TODO: This wait is needed to stop next merge mining task from continuing
When I wait 1 seconds
And mining node MINER mines 1 blocks
Expand Down
Loading

0 comments on commit 4bc7c2a

Please sign in to comment.