Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into fix-storage-overwrite
  • Loading branch information
ctindogaru committed Mar 25, 2022
2 parents 4388e0e + ce1107b commit ca35d49
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 157 deletions.
3 changes: 2 additions & 1 deletion sputnikdao2/tests-ava/__tests__/bounties.ava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
claimBounty,
doneBounty,
giveupBounty,
giveupBountyRaw,
voteApprove,
} from './utils';

Expand Down Expand Up @@ -243,7 +244,7 @@ workspace.test('Bounty giveup', async (test, { alice, root, dao }) => {

//If within forgiveness period, `bounty_bond` should be returned ???
const balance1: NEAR = (await alice.balance()).total;
const result = await giveupBounty(alice, dao, proposalId);
const result = await giveupBountyRaw(alice, dao, proposalId);
const balance2: NEAR = (await alice.balance()).total;
test.is(
Number(balance2.add(result.gas_burnt).toHuman().slice(0, -1)).toFixed(
Expand Down
112 changes: 45 additions & 67 deletions sputnikdao2/tests-ava/__tests__/lib.ava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,36 @@ workspaceWithFactory.test(
]);
const hash = await factory.view('get_default_code_hash', {});

const result = await root
.createTransaction('testdao.factory.test.near')
.functionCall(
'add_proposal',
{
proposal: {
description: 'proposal to test',
kind: {
UpgradeSelf: {
hash: hash,
},
const proposalId: number = await root.call(
'testdao.factory.test.near',
'add_proposal',
{
proposal: {
description: 'proposal to test',
kind: {
UpgradeSelf: {
hash: hash,
},
},
},
{
attachedDeposit: toYocto('1'),
},
)
.signAndSend();
const proposalId = result.parseResult<number>();
},
{
attachedDeposit: toYocto('1'),
},
);
test.is(proposalId, 0);

await root
.createTransaction('testdao.factory.test.near')
.functionCall(
'act_proposal',
{
id: proposalId,
action: 'VoteApprove',
},
{
gas: tGas(300),
},
)
.signAndSend();
await root.call(
'testdao.factory.test.near',
'act_proposal',
{
id: proposalId,
action: 'VoteApprove',
},
{
gas: tGas(300),
},
);
},
);

Expand All @@ -107,13 +102,10 @@ workspaceWithoutInit.test(

// NOT INITIALIZED
let err = await captureError(async () =>
root
.createTransaction(dao)
.functionCall('store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('200'),
gas: tGas(300),
})
.signAndSend(),
root.call(dao, 'store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('200'),
gas: tGas(300),
}),
);
test.regex(err, /ERR_CONTRACT_IS_NOT_INITIALIZED/);

Expand All @@ -122,48 +114,34 @@ workspaceWithoutInit.test(

// not enough deposit
err = await captureError(async () =>
root
.createTransaction(dao)
.functionCall('store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('1'),
gas: tGas(300),
})
.signAndSend(),
root.call(dao, 'store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('1'),
gas: tGas(300),
}),
);
test.regex(err, /ERR_NOT_ENOUGH_DEPOSIT/);

await root
.createTransaction(dao)
.functionCall('store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('200'),
gas: tGas(300),
})
.signAndSend();
await root.call(dao, 'store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('200'),
gas: tGas(300),
});

// Already exists
err = await captureError(async () =>
root
.createTransaction(dao)
.functionCall('store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('200'),
gas: tGas(300),
})
.signAndSend(),
root.call(dao, 'store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('200'),
gas: tGas(300),
}),
);
test.regex(err, /ERR_ALREADY_EXISTS/);
},
);

workspace.test('Remove blob', async (test, { root, dao, alice }) => {
const result = await root
.createTransaction(dao)
.functionCall('store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('200'),
gas: tGas(300),
})
.signAndSend();

const hash = result.parseResult<String>();
const hash: String = await root.call(dao, 'store_blob', DAO_WASM_BYTES, {
attachedDeposit: toYocto('200'),
gas: tGas(300),
});

// fails if hash is wrong
let err = await captureError(async () =>
Expand Down
2 changes: 1 addition & 1 deletion sputnikdao2/tests-ava/__tests__/proposals.ava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ workspace.test(
//Try adding a proposal with 0.999... near
let err = await captureError(
async () =>
await alice.call_raw(
await alice.call(
dao,
'add_proposal',
{
Expand Down
Loading

0 comments on commit ca35d49

Please sign in to comment.