pedrosgmagalhaes / drex_smartcontracts

This GitHub repository contains the smart contract implementation of the Drex Central Bank Digital Currency (CBDC) using Solidity. The contract provides functionalities for managing the digital currency, including minting, transferring, burning, freezing, and checking balances.
Other
49 stars 15 forks source link

Feat: Address Discovery Contract Integration Test Suite #9

Closed pedrosgmagalhaes closed 1 year ago

pedrosgmagalhaes commented 1 year ago

This PR introduces a new test suite for the AddressDiscovery smart contract. The tests ensure the contract's behavior aligns with its intended functionality.

Key changes:

describe("AddressDiscovery", function () {
    it("should allow an account with ACCESS_ROLE to update address", async function () {...});
    it("should not allow an account without ACCESS_ROLE to update address", async function () {...});
    it("admin can change authority", async function () {...});
    it("non-admin can't change authority", async function () {...});
});

Changes

  1. Test Setup: Created a fixture for test setup using loadFixture function from hardhat-network-helpers. The fixture deploys the AddressDiscovery contract and also sets up some accounts for testing.

  2. Role Testing: Wrote tests to ensure that the ACCESS_ROLE is respected when updating addresses in the contract.

  3. Authority Change Testing: Wrote tests to ensure that only an admin can change the authority of the contract.

  4. Helper Methods: Used ethers.js utilities for encoding and hashing data.

Please review these changes and let me know if any further adjustments are needed.