Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iroha2-connector): fix flaky tests to solve #2370 and #2373 #2381

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
import {
generateTestIrohaCredentials,
IrohaV2TestEnv,
waitForCommit,
} from "../test-helpers/iroha2-env-setup";
import { addRandomSuffix } from "../test-helpers/utils";

Expand Down Expand Up @@ -160,18 +159,16 @@ describe("Generate and send signed transaction tests", () => {
// 3. Send
const transactionResponse = await env.apiClient.transactV1({
signedTransaction,
waitForCommit: true,
baseConfig: env.defaultBaseConfig,
});
expect(transactionResponse).toBeTruthy();
expect(transactionResponse.status).toEqual(200);
expect(transactionResponse.data.rejectReason).toBeUndefined();
expect(transactionResponse.data.status).toEqual(
TransactionStatusV1.Submitted,
TransactionStatusV1.Committed,
);

// Sleep
await waitForCommit();

// Check if domain was created
await assertDomainExistence(domainName);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { setCrypto } from "@iroha2/client";
import {
IrohaV2TestEnv,
generateTestIrohaCredentials,
waitForCommit,
} from "../test-helpers/iroha2-env-setup";
import { addRandomSuffix } from "../test-helpers/utils";

Expand Down Expand Up @@ -112,46 +111,6 @@ describe("Setup and basic endpoint tests", () => {
expect(overwrittenConfig).toEqual(requestConfig.torii);
});

test("Simple transaction without waiting and query endpoints works", async () => {
const domainName = addRandomSuffix("singleTxTest");

// Create new domain
const transactionResponse = await env.apiClient.transactV1({
transaction: {
instruction: {
name: IrohaInstruction.RegisterDomain,
params: [domainName],
},
},
baseConfig: env.defaultBaseConfig,
});
expect(transactionResponse).toBeTruthy();
expect(transactionResponse.status).toEqual(200);
expect(transactionResponse.data.status).toBeTruthy();
expect(transactionResponse.data.status).toEqual(
TransactionStatusV1.Submitted,
);
expect(transactionResponse.data.hash).toBeTruthy();
expect(transactionResponse.data.hash.length).toEqual(64);

// Sleep
await waitForCommit();

// Query it
const queryResponse = await env.apiClient.queryV1({
query: {
query: IrohaQuery.FindDomainById,
params: [domainName],
},
baseConfig: env.defaultBaseConfig,
});
expect(queryResponse).toBeTruthy();
expect(queryResponse.data).toBeTruthy();
expect(queryResponse.data.response).toBeTruthy();
expect(queryResponse.data.response.id).toBeTruthy();
expect(queryResponse.data.response.id.name).toEqual(domainName);
});

test("Waiting for transaction commit returns it's status", async () => {
const domainName = addRandomSuffix("waitForTx");

Expand Down