Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/upd-47' into feat/tokenfact…
Browse files Browse the repository at this point in the history
…ory-update
  • Loading branch information
NeverHappened committed Sep 20, 2023
2 parents 55d39bc + 5ab2c66 commit b81080d
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 144 deletions.
21 changes: 1 addition & 20 deletions src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,7 @@ export type AckFailuresResponse = {
type Failure = {
address: string;
id: string;
ack: {
response: {
result: string | null; // base64 encoded bytes
error: string | null; // error text
};
};
ack_type: string;
packet: {
data: string;
destination_channel: string;
destination_port: string;
sequence: string;
source_channel: string;
source_port: string;
timeout_height: {
revision_height: string;
revision_number: string;
};
timeout_timestamp: string;
};
sudo_payload: string; // base64 encoded json bytes
};

export type ScheduleResponse = {
Expand Down
110 changes: 68 additions & 42 deletions src/testcases/parallel/simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,25 +526,54 @@ describe('Neutron / Simple', () => {
expect.objectContaining({
address: contractAddress,
id: '0',
ack_type: 'ack',
}),
expect.objectContaining({
address: contractAddress,
id: '1',
ack_type: 'ack',
}),
expect.objectContaining({
address: contractAddress,
id: '2',
ack_type: 'timeout',
}),
expect.objectContaining({
address: contractAddress,
id: '3',
ack_type: 'timeout',
}),
]);

expect(
JSON.parse(
Buffer.from(
failuresAfterCall.failures[0].sudo_payload,
'base64',
).toString(),
),
).toHaveProperty('response');
expect(
JSON.parse(
Buffer.from(
failuresAfterCall.failures[1].sudo_payload,
'base64',
).toString(),
),
).toHaveProperty('response');
expect(
JSON.parse(
Buffer.from(
failuresAfterCall.failures[2].sudo_payload,
'base64',
).toString(),
),
).toHaveProperty('timeout');
expect(
JSON.parse(
Buffer.from(
failuresAfterCall.failures[3].sudo_payload,
'base64',
).toString(),
),
).toHaveProperty('timeout');

// Restore sudo handler to state
await neutronAccount.executeContract(
contractAddress,
Expand All @@ -554,42 +583,39 @@ describe('Neutron / Simple', () => {
);
});

// TODO: uncomment when LIMIT param is https://www.notion.so/hadron/Gas-Errors-Interchain-Txs-2b2f1caacdcd4981950641e0996cac27 implemented
// then for this test need to add limit low enough to trigger out of gas
// then change later tests length of failures (should be +2 more)
// test('execute contract with sudo out of gas', async () => {
// // Mock sudo handler to fail
// await neutronAccount.executeContract(
// contractAddress,
// JSON.stringify({
// integration_tests_set_sudo_failure_mock: {
// state: 'enabled_infinite_loop',
// },
// }),
// );

// await neutronAccount.executeContract(
// contractAddress,
// JSON.stringify({
// send: {
// channel: 'channel-0',
// to: gaiaAccount.wallet.address.toString(),
// denom: NEUTRON_DENOM,
// amount: '1000',
// },
// }),
// );

// await neutronChain.blockWaiter.waitBlocks(5);

// const res = await getWithAttempts<AckFailuresResponse>(
// neutronChain.blockWaiter,
// async () => neutronChain.queryAckFailures(contractAddress),
// // Wait until there 6 failures in the list
// async (data) => data.failures.length == 6,
// );
// expect(res.failures.length).toEqual(6);
// });
test('execute contract with sudo out of gas', async () => {
// Mock sudo handler to fail
await neutronAccount.executeContract(
contractAddress,
JSON.stringify({
integration_tests_set_sudo_failure_mock: {
state: 'enabled_infinite_loop',
},
}),
);

await neutronAccount.executeContract(
contractAddress,
JSON.stringify({
send: {
channel: 'channel-0',
to: gaiaAccount.wallet.address.toString(),
denom: NEUTRON_DENOM,
amount: '1000',
},
}),
);

await neutronChain.blockWaiter.waitBlocks(5);

const res = await getWithAttempts<AckFailuresResponse>(
neutronChain.blockWaiter,
async () => neutronChain.queryAckFailures(contractAddress),
// Wait until there 6 failures in the list
async (data) => data.failures.length == 6,
);
expect(res.failures.length).toEqual(6);
});

test('failed attempt to resubmit failure', async () => {
// Mock sudo handler to fail
Expand Down Expand Up @@ -626,7 +652,7 @@ describe('Neutron / Simple', () => {
const failuresResAfter = await neutronChain.queryAckFailures(
contractAddress,
);
expect(failuresResAfter.failures.length).toEqual(4);
expect(failuresResAfter.failures.length).toEqual(6);

// Restore sudo handler's normal state
await neutronAccount.executeContract(
Expand Down Expand Up @@ -661,7 +687,7 @@ describe('Neutron / Simple', () => {
const failuresResAfter = await neutronChain.queryAckFailures(
contractAddress,
);
expect(failuresResAfter.failures.length).toEqual(3);
expect(failuresResAfter.failures.length).toEqual(5);
});
});

Expand Down
Loading

0 comments on commit b81080d

Please sign in to comment.