Skip to content

Commit 6b7624c

Browse files
authoredAug 23, 2022
uint64 and uint128 overflow tests (#190)
1 parent a89f4fc commit 6b7624c

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed
 

‎cli/post-install.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ await executeCommand(`mkdir -p binaryen && tar xvf ${BINARYEN_TAR_NAME} --direct
2929
await executeCommand(`rm ${BINARYEN_TAR_NAME}`);
3030

3131
console.log('Installing QuickJS...');
32-
const QUICK_JS_VERSION = `0.1.0`;
32+
const QUICK_JS_VERSION = `0.1.1`;
3333
const QUICK_JS_VERSION_TAG = `v${QUICK_JS_VERSION}`;
3434
const QUICK_JS_SYSTEM_NAME = OS === 'Linux' ? 'Linux' : OS === 'Darwin' ? 'macOS' : 'other';
3535
const QUICK_JS_ARCH_NAME = ARCH === 'x86_64' ? 'X64' : ARCH === 'arm64' ? 'arm64' : 'other';

‎tests/__tests__/test_promise_api.ava.js

+12
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,16 @@ test('promise delete account', async t => {
169169
let r = await bob.callRaw(caller2Contract, 'test_delete_account', '', {gas: '100 Tgas'});
170170
t.is(r.result.status.SuccessValue, '');
171171
t.is(await caller2Contract.getSubAccount('e').exists(), false);
172+
});
173+
174+
test('promise batch transfer overflow', async t => {
175+
const { bob, caller2Contract } = t.context.accounts;
176+
let r = await bob.callRaw(caller2Contract, 'test_transfer_overflow', '', {gas: '100 Tgas'});
177+
t.assert(r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.startsWith('Smart contract panicked: Expect Uint128 for amount'));
178+
});
179+
180+
test('promise create gas overflow', async t => {
181+
const { ali, callerContract } = t.context.accounts;
182+
let r = await ali.callRaw(callerContract, 'test_promise_create_gas_overflow', '', {gas: '100 Tgas'});
183+
t.assert(r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.startsWith('Smart contract panicked: Expect Uint64 for gas'));
172184
});

‎tests/src/promise_api.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export function test_promise_create() {
2525
near.promiseCreate('callee-contract.test.near', 'cross_contract_callee', bytes('abc'), 0, 2 * Math.pow(10, 13))
2626
}
2727

28+
export function test_promise_create_gas_overflow() {
29+
near.promiseCreate('callee-contract.test.near', 'cross_contract_callee', bytes('abc'), 0, BigInt(2) ** BigInt(64))
30+
}
31+
2832
export function test_promise_then() {
2933
let promiseId = near.promiseCreate('callee-contract.test.near', 'cross_contract_callee', bytes('abc'), 0, 2 * Math.pow(10, 13))
3034
near.promiseThen(promiseId, 'caller-contract.test.near', 'cross_contract_callback', bytes('def'), 0, 2 * Math.pow(10, 13))

‎tests/src/promise_batch_api.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)