Skip to content

Commit

Permalink
fix(test): unifying dan layer integration tests (#4175)
Browse files Browse the repository at this point in the history
Description
---
* Solving cucumber tag duplication of `@dan_layer` and `@dan` tags, used only the `@dan` tag in all related tests
* Mark as broken all old tests for the DAN layer, they do not pass anymore
* Mark as broken the recent contract acceptance integration test. Some recent change did seem to broke it, it will be fixed in a separate PR in the future
* For name consistency, renaming the term _"constitution definition"_ for the more appropriate _"contract constitution"_
* Adapted the wallet CLI tests for contract definition and constitution to the new CLI (the `--command` option is no longer valid)
* Tagged the working DAN layer tests as `@critical`, to run them on new PR submissions to avoid breaking changes

Motivation and Context
---
It's desirable to be able to run all DAN related integration tests together under the same tag, and know if we are breaking existing functionalities when developing new features in the future.

How Has This Been Tested?
---
Now, the cucumber integration tests ran with `--tags "@dan and not @broken"` pass
  • Loading branch information
mrnaveira committed Jun 9, 2022
1 parent 998f8aa commit f3495ee
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
3 changes: 3 additions & 0 deletions integration_tests/features/NFT.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

@dan
Feature: NFT

@broken
Scenario: Minting tokens
Given I have a seed node SEED
And I have wallet WALLET_A connected to seed node SEED
Expand All @@ -26,6 +28,7 @@ Feature: NFT
Then I have token TOKEN1 for asset FACTORY on wallet WALLET_B in state ENCUMBEREDTOBERECEIVED
Then I have asset FACTORY on wallet WALLET_A with status ENCUMBEREDTOBERECEIVED

@broken
Scenario: Minting tokens via command line
Given I have a seed node SEED
And I have wallet WALLET_A connected to seed node SEED
Expand Down
4 changes: 3 additions & 1 deletion integration_tests/features/ValidatorNode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

@dan
Feature: Validator Node
@broken
Scenario: Test committee
Given I have committee from 4 validator nodes connected
Then I send instruction successfully with metadata {"issuer" : {"num_clicks" : 1}}
Then At least 3 out of 4 validator nodes have filled asset data

@current
@current @broken
Scenario: Start asset
Given I have a seed node NODE1
And I have wallet WALLET1 connected to all seed nodes
Expand All @@ -20,6 +21,7 @@ Feature: Validator Node
And I create 40 NFTs
And I mine 3 blocks

@broken
Scenario: Publish contract acceptance
Given I have a seed node NODE1
And I have wallet WALLET1 connected to all seed nodes
Expand Down
14 changes: 7 additions & 7 deletions integration_tests/features/WalletCli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,26 @@ Feature: Wallet CLI
And mining node MINE mines 1 blocks
Then WALLET is connected to BASE

@dan_layer
@dan @critical
Scenario: As a user I want to publish a contract definition via command line
Given I have a base node BASE
And I have wallet WALLET connected to base node BASE
And I have mining node MINE connected to base node BASE and wallet WALLET
And mining node MINE mines 4 blocks
Then I wait for wallet WALLET to have at least 1000000 uT
And I create a "contract-definition" from file "fixtures/contract_definition.json" on wallet WALLET via command line
And mining node MINE mines 4 blocks
And I publish a contract definition from file "fixtures/contract_definition.json" on wallet WALLET via command line
And mining node MINE mines 8 blocks
Then wallet WALLET has at least 1 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled
Then WALLET is connected to BASE

@dan_layer
Scenario: As a user I want to publish a constitution definition via command line
@dan @critical
Scenario: As a user I want to publish a contract constitution via command line
Given I have a base node BASE
And I have wallet WALLET connected to base node BASE
And I have mining node MINE connected to base node BASE and wallet WALLET
And mining node MINE mines 4 blocks
Then I wait for wallet WALLET to have at least 1000000 uT
And I create a "constitution-definition" from file "fixtures/constitution_definition.json" on wallet WALLET via command line
And mining node MINE mines 4 blocks
And I publish a contract constitution from file "fixtures/contract_constitution.json" on wallet WALLET via command line
And mining node MINE mines 8 blocks
Then wallet WALLET has at least 1 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled
Then WALLET is connected to BASE
21 changes: 18 additions & 3 deletions integration_tests/features/support/wallet_cli_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,29 @@ Then(
);

Then(
"I create a {string} from file {string} on wallet {word} via command line",
"I publish a contract definition from file {string} on wallet {word} via command line",
{ timeout: 120 * 1000 },
async function (definition_type, relative_file_path, wallet_name) {
async function (relative_file_path, wallet_name) {
let absolute_path = path.resolve(relative_file_path);
let wallet = this.getWallet(wallet_name);
let output = await wallet_run_command(
wallet,
`publish-${definition_type} --json-file ${absolute_path}`
`contract-definition publish ${absolute_path}`
);
console.log(output.buffer);
}
);

Then(
"I publish a contract constitution from file {string} on wallet {word} via command line",
{ timeout: 120 * 1000 },
async function (relative_file_path, wallet_name) {
let absolute_path = path.resolve(relative_file_path);
let wallet = this.getWallet(wallet_name);

let output = await wallet_run_command(
wallet,
`publish-constitution-definition ${absolute_path}`
);
console.log(output.buffer);
}
Expand Down
16 changes: 11 additions & 5 deletions integration_tests/helpers/walletProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ class WalletProcess {
this.options["grpc_console_wallet_address"].match(/tcp\/(\d+)/);
this.grpcPort = parseInt(regexMatch[1]);
}

console.log(`--------------------- ${this.name} ----------------------`);
console.log(overrides);
const configArgs = [];
Object.keys(overrides).forEach((k) => {
args.push("-p");
args.push(`${k}=${overrides[k]}`);
configArgs.push("-p");
configArgs.push(`${k}=${overrides[k]}`);
});
if (saveFile) {
// clear the .env file
Expand All @@ -113,7 +115,7 @@ class WalletProcess {
});
}

const ps = spawn(cmd, args, {
const ps = spawn(cmd, [...configArgs, ...args], {
cwd: this.baseDir,
// shell: true,
env: { ...process.env },
Expand Down Expand Up @@ -278,22 +280,26 @@ class WalletProcess {
".",
"--password",
"kensentme",
"--command",
command,
"--non-interactive",
"--network",
"localnet",
];
if (this.logFilePath) {
args.push("--log-config", this.logFilePath);
}

const overrides = this.getOverrides();
Object.keys(overrides).forEach((k) => {
args.push("-p");
args.push(`${k}=${overrides[k]}`);
});

// Append command arguments
args.push(...command.split(" "));

let output = { buffer: "" };
// In case we killed the wallet fast send enter. Because it will ask for the logs again (e.g. whois test)

await this.run(await this.compile(), args, true, "\n", output, true);
return output;
}
Expand Down

0 comments on commit f3495ee

Please sign in to comment.