Skip to content

Commit

Permalink
test use dict as init parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
volovyks committed Jun 3, 2022
1 parent fbac027 commit 0cd5b4a
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/clean-state/__tests__/test-clean-state.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test.beforeEach(async t => {
const cleanStateContract = await root.createSubAccount('clean-state');
let cleanStateContractBase64 = (await readFile('build/contract.base64')).toString();
await cleanStateContract.call(jsvm, 'deploy_js_contract', Buffer.from(cleanStateContractBase64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await cleanStateContract.call(jsvm, 'call_js_contract', encodeCall(cleanStateContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await cleanStateContract.call(jsvm, 'call_js_contract', encodeCall(cleanStateContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Save state for test runs, it is unique for each test
t.context.worker = worker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ test.beforeEach(async t => {
const statusMessageContract = await root.createSubAccount('status-message');
let statusContractBase64 = (await readFile('res/status-message.base64')).toString();
await statusMessageContract.call(jsvm, 'deploy_js_contract', Buffer.from(statusContractBase64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await statusMessageContract.call(jsvm, 'call_js_contract', encodeCall(statusMessageContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await statusMessageContract.call(jsvm, 'call_js_contract', encodeCall(statusMessageContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Deploy on-call contrat
const onCallContract = await root.createSubAccount('on-call');
let cross_cc_contract_base64 = (await readFile('build/contract.base64')).toString();
await onCallContract.call(jsvm, 'deploy_js_contract', Buffer.from(cross_cc_contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await onCallContract.call(jsvm, 'call_js_contract', encodeCall(onCallContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await onCallContract.call(jsvm, 'call_js_contract', encodeCall(onCallContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Create test accounts
const ali = await root.createSubAccount('ali');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test.beforeEach(async t => {
const fungibleTokenContract = await root.createSubAccount('fungible-token');
let ftContractBase64 = (await readFile('build/contract.base64')).toString();
await fungibleTokenContract.call(jsvm, 'deploy_js_contract', Buffer.from(ftContractBase64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await fungibleTokenContract.call(jsvm, 'call_js_contract', encodeCall(fungibleTokenContract.accountId, 'init', ['a', '1000']), { attachedDeposit: '400000000000000000000000' });
await fungibleTokenContract.call(jsvm, 'call_js_contract', encodeCall(fungibleTokenContract.accountId, 'init', { prefix: 'a', totalSupply: '1000' }), { attachedDeposit: '400000000000000000000000' });

// Create test accounts
const ali = await root.createSubAccount('ali');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.beforeEach(async t => {
const lockableFt = await root.createSubAccount('lockable-ft');
let contract_base64 = (await readFile('build/contract.base64')).toString();
await lockableFt.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '1000000000000000000000000' });
await lockableFt.call(jsvm, 'call_js_contract', encodeCall(lockableFt.accountId, 'init', ['prefix', 10000]), { attachedDeposit: '1000000000000000000000000' });
await lockableFt.call(jsvm, 'call_js_contract', encodeCall(lockableFt.accountId, 'init', { prefix: 'prefix', totalSupply: 10000 }), { attachedDeposit: '1000000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ test.beforeEach(async t => {
const nftContract = await root.createSubAccount('fungible-token');
let nftContractBase64 = (await readFile('build/contract.base64')).toString();
await nftContract.call(jsvm, 'deploy_js_contract', Buffer.from(nftContractBase64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await nftContract.call(jsvm, 'call_js_contract', encodeCall(nftContract.accountId, 'init', [nftContract.accountId, 'prefix']), { attachedDeposit: '400000000000000000000000' });
await nftContract.call(jsvm, 'call_js_contract', encodeCall(nftContract.accountId, 'init', { owner_id: nftContract.accountId, owner_by_id_prefix: 'prefix' }), { attachedDeposit: '400000000000000000000000' });

// Deploy token receiver contract
const tokenReceiverContract = await root.createSubAccount('token-receiver');
let tokenReceiverContractBase64 = (await readFile('build/test-token-receiver.base64')).toString();
await tokenReceiverContract.call(jsvm, 'deploy_js_contract', Buffer.from(tokenReceiverContractBase64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await tokenReceiverContract.call(jsvm, 'call_js_contract', encodeCall(tokenReceiverContract.accountId, 'init', [nftContract.accountId]), { attachedDeposit: '400000000000000000000000' });
await tokenReceiverContract.call(jsvm, 'call_js_contract', encodeCall(tokenReceiverContract.accountId, 'init', { nonFungibleTokenAccountId: nftContract.accountId }), { attachedDeposit: '400000000000000000000000' });

// Mint an NFT
let tokenId = 'my-cool-nft';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.beforeEach(async t => {
const statusMessage = await root.createSubAccount('status-message');
let contract_base64 = (await readFile('build/status-message-collections.base64')).toString();
await statusMessage.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await statusMessage.call(jsvm, 'call_js_contract', encodeCall(statusMessage.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await statusMessage.call(jsvm, 'call_js_contract', encodeCall(statusMessage.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.before(async t => {
const statusMessage = await root.createSubAccount('status-message');
let contract_base64 = (await readFile('build/status-message.base64')).toString();
await statusMessage.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await statusMessage.call(jsvm, 'call_js_contract', encodeCall(statusMessage.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await statusMessage.call(jsvm, 'call_js_contract', encodeCall(statusMessage.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
2 changes: 1 addition & 1 deletion examples/template/__tests__/test-template.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test.beforeEach(async t => {
const counter = await root.createSubAccount('counter');
let contract_base64 = (await readFile('build/contract.base64')).toString();
await counter.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await counter.call(jsvm, 'call_js_contract', encodeCall(counter.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await counter.call(jsvm, 'call_js_contract', encodeCall(counter.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/function-params.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.beforeEach(async t => {
const testContract = await root.createSubAccount('test-contract');
let contract_base64 = (await readFile('build/function-params.base64')).toString();
await testContract.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/lookup-map.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.beforeEach(async t => {
const testContract = await root.createSubAccount('test-contract');
let contract_base64 = (await readFile('build/lookup-map.base64')).toString();
await testContract.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/lookup-set.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.beforeEach(async t => {
const testContract = await root.createSubAccount('test-contract');
let contract_base64 = (await readFile('build/lookup-set.base64')).toString();
await testContract.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/unordered-map.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.beforeEach(async t => {
const testContract = await root.createSubAccount('test-contract');
let contract_base64 = (await readFile('build/unordered-map.base64')).toString();
await testContract.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/unordered-set.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.beforeEach(async t => {
const testContract = await root.createSubAccount('test-contract');
let contract_base64 = (await readFile('build/unordered-set.base64')).toString();
await testContract.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/vector.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.beforeEach(async t => {
const testContract = await root.createSubAccount('test-contract');
let contract_base64 = (await readFile('build/vector.base64')).toString();
await testContract.call(jsvm, 'deploy_js_contract', Buffer.from(contract_base64, 'base64'), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', []), { attachedDeposit: '400000000000000000000000' });
await testContract.call(jsvm, 'call_js_contract', encodeCall(testContract.accountId, 'init', {}), { attachedDeposit: '400000000000000000000000' });

// Test users
const ali = await root.createSubAccount('ali');
Expand Down

0 comments on commit 0cd5b4a

Please sign in to comment.