Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Add a test for issue183 (#185)
Browse files Browse the repository at this point in the history
* Add a test for issue183
  • Loading branch information
dnkolegov authored Aug 9, 2023
1 parent c986c1e commit 0b21902
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/SubnetActorDiamond.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,43 @@ contract SubnetActorDiamondTest is Test {
saManager.join{value: amount}(DEFAULT_NET_ADDR, FvmAddress({addrType: 1, payload: new bytes(20)}));

require(saGetter.validatorCount() == 0);
require(gwGetter.listSubnets().length == 0);
}

function testSubnetActorDiamond_Join_Works_MultipleNewValidators() public {
_assertJoin(vm.addr(1234), DEFAULT_MIN_VALIDATOR_STAKE);
_assertJoin(vm.addr(1235), DEFAULT_MIN_VALIDATOR_STAKE);

require(saGetter.validatorCount() == 2);
require(gwGetter.listSubnets().length == 1);
}

function testSubnetActorDiamond_Join_Works_OneValidatorWithMinimumStake() public {
require(gwGetter.listSubnets().length == 0, "listSubnets correct");
require(saGetter.validatorCount() == 0, "validatorCount correct");

address validator = vm.addr(1234);

vm.startPrank(validator);
vm.deal(validator, DEFAULT_MIN_VALIDATOR_STAKE);

require(validator.balance == DEFAULT_MIN_VALIDATOR_STAKE, "balance() == DEFAULT_MIN_VALIDATOR_STAKE");
require(saGetter.stake(validator) == 0, "stake(validator) == 0");
require(saGetter.totalStake() == 0, "totalStake() == 0");

saManager.join{value: DEFAULT_MIN_VALIDATOR_STAKE}(
DEFAULT_NET_ADDR,
FvmAddress({addrType: 1, payload: new bytes(20)})
);

require(saGetter.stake(validator) == DEFAULT_MIN_VALIDATOR_STAKE);
require(saGetter.totalStake() == DEFAULT_MIN_VALIDATOR_STAKE);
require(validator.balance == 0);

vm.stopPrank();

require(saGetter.validatorCount() == 1, "validatorCount() correct");
require(gwGetter.listSubnets().length == 1, "listSubnets() correct");
}

function testSubnetActorDiamond_Join_Works_NoNewValidator_CollateralNotEnough() public {
Expand Down

0 comments on commit 0b21902

Please sign in to comment.