Skip to content

Commit

Permalink
test: SAF cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Aug 16, 2021
1 parent f1d297b commit ddcb400
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 54 deletions.
87 changes: 53 additions & 34 deletions integration_tests/features/WalletRoutingMechanism.feature
Original file line number Diff line number Diff line change
@@ -1,43 +1,62 @@
@routing_mechanism
Feature: Wallet Routing Mechanism

Scenario Outline: Wallets transacting via specified routing mechanism only
Given I have a seed node NODE
And I have <NumBaseNodes> base nodes connected to all seed nodes
And I have non-default wallet WALLET_A connected to all seed nodes using <Mechanism>
And I have mining node MINER connected to base node NODE and wallet WALLET_A
And I have <NumWallets> non-default wallets connected to all seed nodes using <Mechanism>
And I have a merge mining proxy PROXY connected to NODE and WALLET_A with default config
Scenario Outline: Wallets transacting via specified routing mechanism only
Given I have a seed node NODE
And I have <NumBaseNodes> base nodes connected to all seed nodes
And I have non-default wallet WALLET_A connected to all seed nodes using <Mechanism>
And I have mining node MINER connected to base node NODE and wallet WALLET_A
And I have <NumWallets> non-default wallets connected to all seed nodes using <Mechanism>
And I have a merge mining proxy PROXY connected to NODE and WALLET_A with default config
# We need to ensure the coinbase lock heights are gone and we have enough individual UTXOs; mine enough blocks
When I merge mine 20 blocks via PROXY
Then all nodes are at height 20
When I merge mine 20 blocks via PROXY
Then all nodes are at height 20
# TODO: This wait is needed to stop base nodes from shutting down
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 100
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
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 100
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
# 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
Then all nodes are at height 21
Then all wallets detect all transactions as Mined_Unconfirmed
When I wait 1 seconds
And mining node MINER mines 1 blocks
Then all nodes are at height 21
Then all wallets detect all transactions as Mined_Unconfirmed
# TODO: This wait is needed to stop next merge mining task from continuing
When I wait 1 seconds
And mining node MINER mines 11 blocks
Then all nodes are at height 32
Then all wallets detect all transactions as Mined_Confirmed
When I wait 1 seconds
And mining node MINER mines 11 blocks
Then all nodes are at height 32
Then all wallets detect all transactions as Mined_Confirmed
# TODO: This wait is needed to stop base nodes from shutting down
When I wait 1 seconds
@critical
Examples:
| NumBaseNodes | NumWallets | Mechanism |
| 5 | 5 | DirectAndStoreAndForward |
| 5 | 5 | DirectOnly |
When I wait 1 seconds
@critical
Examples:
| NumBaseNodes | NumWallets | Mechanism |
| 5 | 5 | DirectAndStoreAndForward |
| 5 | 5 | DirectOnly |

@long-running
Examples:
| NumBaseNodes | NumWallets | Mechanism |
| 5 | 5 | StoreAndForwardOnly |
@long-running
Examples:
| NumBaseNodes | NumWallets | Mechanism |
| 5 | 5 | StoreAndForwardOnly |

# TODO: lower the sleeps
Scenario: Store and forward TX
And I have a base node BASE
And I have wallet SENDER connected to base node BASE
And I have wallet RECEIVER connected to base node BASE
And I stop wallet RECEIVER
And I have mining node MINE connected to base node BASE and wallet SENDER
And mining node MINE mines 5 blocks
Then I wait for wallet SENDER to have at least 1000000 uT
And I send 1000000 uT from wallet SENDER to wallet RECEIVER at fee 100
And I wait 121 seconds
And I stop wallet SENDER
And I wait 360 seconds
And I restart wallet RECEIVER
And I wait 121 seconds
And I stop wallet RECEIVER
And I restart wallet SENDER
And wallet SENDER detects all transactions are at least Broadcast
35 changes: 15 additions & 20 deletions integration_tests/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -1423,16 +1423,14 @@ Then(

async function send_tari(
sourceWallet,
destWallet,
destWalletPubkey,
tariAmount,
feePerGram,
oneSided = false,
message = "",
printMessage = true
) {
const sourceWalletClient = await sourceWallet.connectClient();
const destClient = await destWallet.connectClient();
const destInfo = await destClient.identify();
if (message === "") {
message =
sourceWallet.name +
Expand All @@ -1441,9 +1439,9 @@ async function send_tari(
"uT one-sided(" +
oneSided +
") to " +
destWallet.name +
// destWallet.name +
" `" +
destInfo.public_key +
destWalletPubkey +
"`";
}
if (printMessage) {
Expand All @@ -1461,7 +1459,7 @@ async function send_tari(
lastResult = await sourceWalletClient.transfer({
recipients: [
{
address: destInfo.public_key,
address: destWalletPubkey,
amount: tariAmount,
fee_per_gram: feePerGram,
message: message,
Expand All @@ -1472,7 +1470,7 @@ async function send_tari(
lastResult = await sourceWalletClient.transfer({
recipients: [
{
address: destInfo.public_key,
address: destWalletPubkey,
amount: tariAmount,
fee_per_gram: feePerGram,
message: message,
Expand Down Expand Up @@ -1521,12 +1519,10 @@ When(
const sourceClient = await sourceWallet.connectClient();
const sourceInfo = await sourceClient.identify();

const destWallet = this.getWallet(dest);
const destClient = await destWallet.connectClient();
const destInfo = await destClient.identify();
const destWalletPubkey = this.getWalletPubkey(dest);
this.lastResult = await send_tari(
sourceWallet,
destWallet,
destWalletPubkey,
tariAmount,
feePerGram
);
Expand All @@ -1536,7 +1532,7 @@ When(
this.lastResult.results[0].transaction_id
);
this.addTransaction(
destInfo.public_key,
destWalletPubkey,
this.lastResult.results[0].transaction_id
);
console.log(
Expand All @@ -1556,12 +1552,11 @@ When(
console.log("\n");
const sourceClient = await this.getWallet(source).connectClient();
const sourceInfo = await sourceClient.identify();
const destClient = await this.getWallet(dest).connectClient();
const destInfo = await destClient.identify();
const destWalletPubkey = this.getWalletPubkey(dest);
for (let i = 0; i < number; i++) {
this.lastResult = await send_tari(
this.getWallet(source),
this.getWallet(dest),
destWalletPubkey,
tariAmount,
fee
);
Expand All @@ -1571,7 +1566,7 @@ When(
this.lastResult.results[0].transaction_id
);
this.addTransaction(
destInfo.public_key,
destWalletPubkey,
this.lastResult.results[0].transaction_id
);
// console.log(" Transaction '" + this.lastResult.results[0]["transaction_id"] + "' is_success(" +
Expand All @@ -1595,7 +1590,7 @@ When(
const destInfo = await destClient.identify();
this.lastResult = await send_tari(
this.getWallet(source),
this.getWallet(wallet),
destInfo.public_key,
tariAmount,
fee
);
Expand Down Expand Up @@ -1718,7 +1713,7 @@ When(
const sourceInfo = await sourceClient.identify();
this.lastResult = await send_tari(
this.getWallet(source),
this.getWallet(source),
this.getWalletPubkey(source),
tariAmount,
feePerGram
);
Expand Down Expand Up @@ -1785,7 +1780,7 @@ When(
const oneSided = true;
const lastResult = await send_tari(
this.getWallet(source),
this.getWallet(dest),
this.getWalletPubkey(dest),
amount,
feePerGram,
oneSided
Expand Down Expand Up @@ -2869,7 +2864,7 @@ When(
for (let i = 0; i < numTransactions; i++) {
const result = await send_tari(
this.getWallet(sourceWallet),
this.getWallet(destWallet),
this.getWalletPubkey(destWallet),
amount,
feePerGram,
false,
Expand Down

0 comments on commit ddcb400

Please sign in to comment.