Skip to content

Commit

Permalink
uint64 and uint128 overflow tests (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ailisp authored Aug 23, 2022
1 parent a89f4fc commit 6b7624c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/post-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ await executeCommand(`mkdir -p binaryen && tar xvf ${BINARYEN_TAR_NAME} --direct
await executeCommand(`rm ${BINARYEN_TAR_NAME}`);

console.log('Installing QuickJS...');
const QUICK_JS_VERSION = `0.1.0`;
const QUICK_JS_VERSION = `0.1.1`;
const QUICK_JS_VERSION_TAG = `v${QUICK_JS_VERSION}`;
const QUICK_JS_SYSTEM_NAME = OS === 'Linux' ? 'Linux' : OS === 'Darwin' ? 'macOS' : 'other';
const QUICK_JS_ARCH_NAME = ARCH === 'x86_64' ? 'X64' : ARCH === 'arm64' ? 'arm64' : 'other';
Expand Down
12 changes: 12 additions & 0 deletions tests/__tests__/test_promise_api.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,16 @@ test('promise delete account', async t => {
let r = await bob.callRaw(caller2Contract, 'test_delete_account', '', {gas: '100 Tgas'});
t.is(r.result.status.SuccessValue, '');
t.is(await caller2Contract.getSubAccount('e').exists(), false);
});

test('promise batch transfer overflow', async t => {
const { bob, caller2Contract } = t.context.accounts;
let r = await bob.callRaw(caller2Contract, 'test_transfer_overflow', '', {gas: '100 Tgas'});
t.assert(r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.startsWith('Smart contract panicked: Expect Uint128 for amount'));
});

test('promise create gas overflow', async t => {
const { ali, callerContract } = t.context.accounts;
let r = await ali.callRaw(callerContract, 'test_promise_create_gas_overflow', '', {gas: '100 Tgas'});
t.assert(r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.startsWith('Smart contract panicked: Expect Uint64 for gas'));
});
4 changes: 4 additions & 0 deletions tests/src/promise_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export function test_promise_create() {
near.promiseCreate('callee-contract.test.near', 'cross_contract_callee', bytes('abc'), 0, 2 * Math.pow(10, 13))
}

export function test_promise_create_gas_overflow() {
near.promiseCreate('callee-contract.test.near', 'cross_contract_callee', bytes('abc'), 0, BigInt(2) ** BigInt(64))
}

export function test_promise_then() {
let promiseId = near.promiseCreate('callee-contract.test.near', 'cross_contract_callee', bytes('abc'), 0, 2 * Math.pow(10, 13))
near.promiseThen(promiseId, 'caller-contract.test.near', 'cross_contract_callback', bytes('def'), 0, 2 * Math.pow(10, 13))
Expand Down
7 changes: 7 additions & 0 deletions tests/src/promise_batch_api.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6b7624c

Please sign in to comment.