git.delta.rocks / unique-network / refs/commits / bebe7844b72b

difftreelog

eth/allowList migrated

rkv2022-09-26parent: #076b5dc.patch.diff
in: master

1 file changed

modifiedtests/src/eth/allowlist.test.tsdiffbeforeafterboth
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18import {expect} from 'chai';
19import {isAllowlisted, normalizeAccountId} from '../util/helpers';
20import {
21 contractHelpers,
22 createEthAccount,
23 createEthAccountWithBalance,
24 deployFlipper,
25 evmCollection,
26 evmCollectionHelpers,
27 getCollectionAddressFromResult,
28 itWeb3,
29} from './util/helpers';
30import {itEth, usingEthPlaygrounds} from './util/playgrounds';18import {itEth, usingEthPlaygrounds, expect} from './util/playgrounds';
3119
32describe('EVM contract allowlist', () => {20describe('EVM contract allowlist', () => {
21 let donor: IKeyringPair;
22
23 before(async function() {
24 await usingEthPlaygrounds(async (_helper, privateKey) => {
25 donor = privateKey('//Alice');
26 });
27 });
28
33 itWeb3('Contract allowlist can be toggled', async ({api, web3, privateKeyWrapper}) => {29 itEth('Contract allowlist can be toggled', async ({helper}) => {
34 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);30 const owner = await helper.eth.createAccountWithBalance(donor);
35 const flipper = await deployFlipper(web3, owner);31 const flipper = await helper.eth.deployFlipper(owner);
36
37 const helpers = contractHelpers(web3, owner);32 const helpers = helper.ethNativeContract.contractHelpers(owner);
3833
39 // Any user is allowed by default34 // Any user is allowed by default
40 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;35 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;
48 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;43 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;
49 });44 });
5045
51 itWeb3('Non-allowlisted user can\'t call contract with allowlist enabled', async ({api, web3, privateKeyWrapper}) => {46 itEth('Non-allowlisted user can\'t call contract with allowlist enabled', async ({helper}) => {
52 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);47 const owner = await helper.eth.createAccountWithBalance(donor);
53 const flipper = await deployFlipper(web3, owner);48 const caller = await helper.eth.createAccountWithBalance(donor);
54 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);49 const flipper = await helper.eth.deployFlipper(owner);
55
56 const helpers = contractHelpers(web3, owner);50 const helpers = helper.ethNativeContract.contractHelpers(owner);
5751
58 // User can flip with allowlist disabled52 // User can flip with allowlist disabled
59 await flipper.methods.flip().send({from: caller});53 await flipper.methods.flip().send({from: caller});