Skip to content

Commit

Permalink
test(test-sol/integration): adds e2e test for GoldToken
Browse files Browse the repository at this point in the history
This is a test run, to see how `setUp()` and contract definitions work.

1. run devchain

```sh
./migrations_sol/create_and_migrate_anvil_devchain.sh
```

2. run test against devchain

```sh
forge test \
--match-path test-sol/integration/Integration.t.sol \
--match-contract GoldTokenTest_General \
-vvv \
--fork-url http://127.0.0.1:8546
```

Tests pass

Output:

```sh
[⠰] Compiling...
No files changed, compilation skipped

Running 3 tests for test-sol/integration/Integration.t.sol:GoldTokenTest_General
[PASS] test_decimals() (gas: 10837)
Logs:
  GoldToken address is: 0xfE8CbC1cFA1b3b8256f310bdfd40E60597083448

[PASS] test_name() (gas: 12537)
Logs:
  GoldToken address is: 0xfE8CbC1cFA1b3b8256f310bdfd40E60597083448

[PASS] test_symbol() (gas: 12579)
Logs:
  GoldToken address is: 0xfE8CbC1cFA1b3b8256f310bdfd40E60597083448

Test result: ok. 3 passed; 0 failed; 0 skipped; finished in 135.40ms

Ran 1 test suites: 3 tests passed, 0 failed, 0 skipped (3 total tests)
```
  • Loading branch information
arthurgousset committed May 28, 2024
1 parent 3ae51c4 commit ee24877
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions packages/protocol/test-sol/integration/Integration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,38 @@ pragma solidity ^0.5.13;

import "celo-foundry/Test.sol";
import "@celo-contracts/common/GoldToken.sol";
// import "@celo-contracts/common/test/MockGoldToken.sol";
import "forge-std/console.sol";
import "@celo-contracts/common/interfaces/IRegistry.sol";
import "@celo-contracts/common/GoldToken.sol";
import "@celo-contracts/common/UsingRegistry.sol";
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "forge-std/console2.sol";

contract IntegrationTest is Test {
address constant registryAddress = address(0x000000000000000000000000000000000000ce10);
contract IntegrationTest is Test, UsingRegistry {
address account1 = actor("account1");
address account2 = actor("account2");
address constant registryAddress = address(0x000000000000000000000000000000000000ce10);
IRegistry registry = IRegistry(registryAddress);
GoldToken goldToken;

function setUp() public {}

function test_dummy() public {}
}

contract GoldTokenTest_General is IntegrationTest {
function setUp() public {
goldToken = GoldToken(registry.getAddressForStringOrDie("GoldToken"));
console2.log("GoldToken address is:", address(goldToken));
}

function test_name() public {
assertEq(goldToken.name(), "Celo native asset");
}

function test_symbol() public {
assertEq(goldToken.symbol(), "CELO");
}

function test_decimals() public {
assertEq(uint256(goldToken.decimals()), 18);
}
}

0 comments on commit ee24877

Please sign in to comment.