Skip to content

Commit

Permalink
Merge tari-project#2900: [tests] Fix cucumber test (tari-project#2900)
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed May 9, 2021
2 parents a333724 + cc6e524 commit 9d01317
Show file tree
Hide file tree
Showing 23 changed files with 1,844 additions and 625 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ commands:
- run:
name: Check formatting
command: cd integration_tests && npm run check-fmt
- run:
name: Check eslint
command: cd integration_tests && npm run lint
- run:
name: Pre-build base node
command: cargo build --release --bin tari_base_node
Expand Down
12 changes: 11 additions & 1 deletion applications/utils/washing_machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ async function doSend(senderClient, receiverClient, amount) {
});
console.log("Split:", split_result);
}
// TODO wait for split to be mined

// wait for balance to become available
for (let i = 0; i< 20*60; i++) {

let newBalance = await senderClient.getBalance();
console.log(`Waiting for new balance (spender) ${newBalance.available_balance} to be more than required amount: ${amount}. Pending ${newBalance.pending_balance}`);
if (parseInt(newBalance.available_balance) >= amount) {
break;
}
await sleep(1000);
}
let senderBalance = await senderClient.getBalance();
console.log("Sender: ", senderBalance);
let balance = await receiverClient.getBalance();
Expand Down
25 changes: 25 additions & 0 deletions integration_tests/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"env": {
"browser": true,
"commonjs": true,
"node": true,
"es2021": true
},
"rules": {
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
"prettier/prettier": [
"error",
{
"doubleQuote": true,
"endOfLine": "auto"
}
]
}
}
1 change: 1 addition & 0 deletions integration_tests/.husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
13 changes: 13 additions & 0 deletions integration_tests/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# run prettier and lint check before commit if any files in integration_tests have been staged
CHECK=$(git diff --name-only --staged | grep -i integration_tests || true)

if [ -z "${CHECK}" ]; then
exit 0
else
echo "Files staged for commit in integration_tests/"
echo "Running pre-commit hook"
cd integration_tests && npm run check-fmt && npm run lint
fi
3 changes: 3 additions & 0 deletions integration_tests/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"endOfLine": "auto"
}
21 changes: 10 additions & 11 deletions integration_tests/features/Reorgs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ Feature: Reorgs

@critical
Scenario: Simple reorg to stronger chain
Given I have a seed node SA
And I have a base node B connected to seed SA
Given I have a base node B
And I have wallet WB connected to base node B
And I have mining node BM connected to base node B and wallet WB
When I stop SA
And mining node BM mines 3 blocks
Given I have a base node C connected to seed SA
And mining node BM mines 3 blocks with min difficulty 1 and max difficulty 1
Given I have a base node C
And I have wallet WC connected to base node C
And I have mining node CM connected to base node C and wallet WC
And mining node CM mines 15 blocks
And mining node CM mines 10 blocks with min difficulty 1 and max difficulty 9999999999
Then node B is at height 3
And node C is at height 15
When I start SA
Then node B is at height 15
And node C is at height 15
And node SA is at height 15
And node C is at height 10
Given I have a base node SA connected to nodes B,C
Then node SA is at height 10
And node B is at height 10
And node C is at height 10

@critical
Scenario: Node rolls back reorg on invalid block
Expand All @@ -39,6 +37,7 @@ Feature: Reorgs
Given I have a base node NODE1 connected to all seed nodes
When I mine a block on NODE1 with coinbase CB1
Given I have a base node NODE2 connected to node NODE1
Then all nodes are at height 1
And I stop NODE1
When I mine 19 blocks on NODE2
And node NODE2 is at height 20
Expand Down
7 changes: 4 additions & 3 deletions integration_tests/features/WalletTransfer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Feature: Wallet Transfer
# Add a 2nd node otherwise initial sync will not succeed
And I have 1 base nodes connected to all seed nodes
And I have wallet Wallet_A connected to all seed nodes
And I have a merge mining proxy PROXY connected to NODE and Wallet_A with default config
And I have a merge mining proxy PROXY connected to NODE and Wallet_A with default config
And I have mining node MINER connected to base node NODE and wallet Wallet_A
And I have wallet Wallet_B connected to all seed nodes
And I have wallet Wallet_C connected to all seed nodes
Expand All @@ -28,8 +28,9 @@ Feature: Wallet Transfer
When I merge mine 5 blocks via PROXY
Then all nodes are at height 5
# Ensure the coinbase lock heights have expired
And I have mining node MINER connected to base node NODE and wallet WC
And mining node MINER mines 3 blocks
When I transfer 50000 uT to self from wallet Wallet_A at fee 25
And mining node MINER mines 5 blocks
Then all nodes are at height 15
Then all wallets detect all transactions as Mined_Confirmed
Then all nodes are at height 13
Then wallet Wallet_A detects all transactions as Mined_Confirmed
Loading

0 comments on commit 9d01317

Please sign in to comment.