github.com/cgcardona/r-subnet-evm@v0.1.5/contracts/test/tx_allow_list.ts (about) 1 // (c) 2019-2022, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 import { ethers } from "hardhat" 5 import { test } from "./utils" 6 7 // make sure this is always an admin for minter precompile 8 const ADMIN_ADDRESS = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC" 9 const OTHER_SIGNER = "0x0Fa8EA536Be85F32724D57A37758761B86416123" 10 const TX_ALLOW_LIST_ADDRESS = "0x0200000000000000000000000000000000000002" 11 12 describe("ExampleTxAllowList", function () { 13 beforeEach('Setup DS-Test contract', async function () { 14 const signer = await ethers.getSigner(ADMIN_ADDRESS) 15 const allowListPromise = ethers.getContractAt("IAllowList", TX_ALLOW_LIST_ADDRESS, signer) 16 17 return ethers.getContractFactory("ExampleTxAllowListTest", { signer }) 18 .then(factory => factory.deploy()) 19 .then(contract => { 20 this.testContract = contract 21 return Promise.all([ 22 contract.deployed().then(() => contract), 23 allowListPromise.then(allowList => allowList.setAdmin(contract.address)).then(tx => tx.wait()), 24 ]) 25 }) 26 .then(([contract]) => contract.setUp()) 27 .then(tx => tx.wait()) 28 }) 29 30 test("should add contract deployer as admin", "step_contractOwnerIsAdmin") 31 32 test("precompile should see admin address has admin role", "step_precompileHasDeployerAsAdmin") 33 34 test("precompile should see test address has no role", "step_newAddressHasNoRole") 35 36 test("contract should report test address has on admin role", "step_noRoleIsNotAdmin") 37 38 test("contract should report admin address has admin role", "step_exmapleAllowListReturnsTestIsAdmin") 39 40 test("should not let test address submit txs", [ 41 { 42 method: "step_fromOther", 43 overrides: { from: OTHER_SIGNER }, 44 shouldFail: true, 45 }, 46 { 47 method: "step_enableOther", 48 overrides: { from: ADMIN_ADDRESS }, 49 shouldFail: false, 50 }, 51 { 52 method: "step_fromOther", 53 overrides: { from: OTHER_SIGNER }, 54 shouldFail: false, 55 }, 56 ]); 57 58 test("should not allow noRole to enable itself", "step_noRoleCannotEnableItself") 59 60 test("should allow admin to add contract as admin", "step_addContractAsAdmin") 61 62 test("should allow admin to add allowed address as allowed through contract", "step_enableThroughContract") 63 64 test("should let allowed address deploy", "step_canDeploy") 65 66 test("should not let allowed add another allowed", "step_onlyAdminCanEnable") 67 68 test("should not let allowed to revoke admin", "step_onlyAdminCanRevoke") 69 70 test("should let admin to revoke allowed", "step_adminCanRevoke") 71 })