github.com/cgcardona/r-subnet-evm@v0.1.5/contracts/test/reward_manager.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 reward manager precompile
     8  const ADMIN_ADDRESS = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
     9  const REWARD_MANAGER_ADDRESS = "0x0200000000000000000000000000000000000004"
    10  
    11  describe("ExampleRewardManager", function () {
    12    this.timeout("30s")
    13  
    14    beforeEach('Setup DS-Test contract', async function () {
    15      const signer = await ethers.getSigner(ADMIN_ADDRESS)
    16      const rewardManagerPromise = ethers.getContractAt("IRewardManager", REWARD_MANAGER_ADDRESS, signer)
    17  
    18      return ethers.getContractFactory("ExampleRewardManagerTest", { signer })
    19        .then(factory => factory.deploy())
    20        .then(contract => {
    21          this.testContract = contract
    22          return contract.deployed().then(() => contract)
    23        })
    24        .then(contract => contract.setUp())
    25        .then(tx => Promise.all([rewardManagerPromise, tx.wait()]))
    26        .then(([rewardManager]) => rewardManager.setAdmin(this.testContract.address))
    27        .then(tx => tx.wait())
    28    })
    29  
    30    test("should send fees to blackhole", ["step_captureBlackholeBalance", "step_checkSendFeesToBlackhole"])
    31  
    32    test("should not appoint reward address before enabled", "step_doesNotSetRewardAddressBeforeEnabled")
    33  
    34    test("contract should be added to enabled list", "step_setEnabled")
    35  
    36    test("should be appointed as reward address", "step_setRewardAddress")
    37  
    38    // we need to change the fee receiver, send a transaction for the new receiver to receive fees, then check the balance change. 
    39    // the new fee receiver won't receive fees in the same block where it was set.
    40    test("should be able to receive fees", ["step_setupReceiveFees", "step_receiveFees", "step_checkReceiveFees"])
    41  
    42    test("should return false for allowFeeRecipients check", "step_areFeeRecipientsAllowed")
    43  
    44    test("should enable allowFeeRecipients", "step_allowFeeRecipients")
    45  
    46    test("should disable reward address", "step_disableRewardAddress")
    47  });