Skip to content

Commit

Permalink
testing exchang func (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
thurendous committed Sep 9, 2024
1 parent 35aa9b0 commit e665318
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions test/integration/VotingPowerExchange.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

pragma solidity 0.8.24;

import {DeployContracts, DeploymentResult} from "script/DeployContracts.s.sol";
import {Test, console} from "forge-std/Test.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import {AmbassadorNft} from "src/AmbassadorNft.sol";
import {DeployContracts, DeploymentResult} from "script/DeployContracts.s.sol";
import {ERC20UpgradeableTokenV1} from "src/ERC20UpgradeableTokenV1.sol";
import {GovToken} from "src/GovToken.sol";
import {VotingPowerExchange} from "src/VotingPowerExchange.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import {VotingPowerExchangeTestHelper} from "./utils/VotingPowerExchangeTestHelper.t.sol";

contract VotingPwoerExchangeTest is Test {
// instances
GovToken public govToken;
ERC20UpgradeableTokenV1 public utilityToken;
VotingPowerExchange public votingPowerExchange;
DeployContracts public dc;
VotingPowerExchangeTestHelper public helper;

DeploymentResult result;

Expand Down Expand Up @@ -60,6 +62,16 @@ contract VotingPwoerExchangeTest is Test {
utilityToken.mint(participant, 100_000 * 1e18);
utilityToken.mint(participant2, 10_000 * 1e18);
vm.stopPrank();

// set up the roles for exchange contract

helper = new VotingPowerExchangeTestHelper();

// other setup
vm.label(participant, "participant");
vm.label(participant2, "participant2");
vm.label(user, "user");
vm.label(user2, "user2");
}

function testReturnedSetupValues() public view {
Expand Down Expand Up @@ -384,4 +396,11 @@ contract VotingPwoerExchangeTest is Test {
}

/////// Exchange tests ///////
function testExchangeCase1() public {
bytes32 nonce = bytes32(0);
bytes memory signature = helper.generateSignatureFromPrivateKey(dc.DEFAULT_ANVIL_KEY2(), 620 * 1e18, nonce, block.timestamp + 3600);
vm.startPrank(exchanger);
votingPowerExchange.exchange(participant, 100_000 * 1e18, nonce, block.timestamp + 3600, signature);
vm.stopPrank();
}
}
2 changes: 1 addition & 1 deletion test/integration/utils/VotingPowerExchangeTestHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract VotingPowerExchangeTestHelper is Test {
bytes32 private constant _EXCHANGE_TYPEHASH =
keccak256("Exchange(address sender,uint256 amount,bytes32 nonce,uint256 expiration)");

function generateSignatureFromPrivateKey(uint256 privateKey, uint256 amount, uint256 nonce, uint256 expiration)
function generateSignatureFromPrivateKey(uint256 privateKey, uint256 amount, bytes32 nonce, uint256 expiration)
public
view
returns (bytes memory)
Expand Down

0 comments on commit e665318

Please sign in to comment.