From af1c5e9280d165d6e57d4fa6c4cdc4873912c0f9 Mon Sep 17 00:00:00 2001 From: rndquu Date: Thu, 11 May 2023 20:01:24 +0300 Subject: [PATCH] test: remove difficulty from UbiquiStick tests --- cspell.json | 1 + .../test/ubiquistick/UbiquiStick.t.sol | 42 ++++++++----------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/cspell.json b/cspell.json index ed3397835..8c1d3925d 100644 --- a/cspell.json +++ b/cspell.json @@ -91,6 +91,7 @@ "ntype", "opentype", "Pausable", + "prevrandao", "proto", "psender", "Qmanager", diff --git a/packages/contracts/test/ubiquistick/UbiquiStick.t.sol b/packages/contracts/test/ubiquistick/UbiquiStick.t.sol index 106ca3464..5182cf326 100644 --- a/packages/contracts/test/ubiquistick/UbiquiStick.t.sol +++ b/packages/contracts/test/ubiquistick/UbiquiStick.t.sol @@ -65,22 +65,19 @@ contract UbiquiStickTest is Test { function testTokenURI_ShouldReturnTokenURIForTokenTypeGold() public { // set gold token URI - vm.prank(minter); + vm.startPrank(minter); ubiquiStick.setTokenURI(GOLD_TYPE, "TOKEN_URI_GOLD"); // mint gold token - // mint 80 tokens to user (needed for random() to return a gold type) - for (uint i = 1; i <= 80; i++) { - vm.prank(minter); + // mint 57 tokens to user (needed for random() to return a gold type) + for (uint i = 1; i <= 57; i++) { ubiquiStick.safeMint(user); } - // mock EVM values so that random() could return a gold token - vm.warp(1); - vm.difficulty(81); - // mint 81st gold token - vm.prank(minter); + // with the default "block.prevrandao = 0" the 58th token is gold ubiquiStick.safeMint(user); - assertEq(ubiquiStick.tokenURI(81), "TOKEN_URI_GOLD"); + assertEq(ubiquiStick.tokenURI(58), "TOKEN_URI_GOLD"); + + vm.stopPrank(); } function testTokenURI_ShouldReturnTokenURIForTokenTypeInvisible() public { @@ -140,21 +137,17 @@ contract UbiquiStickTest is Test { } function testSafeMint_ShouldMintGoldToken() public { - // mint 80 tokens to user (needed for random() to return a gold type) - for (uint i = 1; i <= 80; i++) { - vm.prank(minter); + vm.startPrank(minter); + // mint 57 tokens to user (needed for random() to return a gold type) + for (uint i = 1; i <= 57; i++) { ubiquiStick.safeMint(user); } - - // mock EVM values so that random() could return a gold token - vm.warp(1); - vm.difficulty(81); - - // mint 81st token - vm.prank(minter); + // with the default "block.prevrandao = 0" the 58th token is gold ubiquiStick.safeMint(user); - assertEq(ubiquiStick.ownerOf(81), user); - assertEq(ubiquiStick.gold(81), true); + assertEq(ubiquiStick.ownerOf(58), user); + assertEq(ubiquiStick.gold(58), true); + + vm.stopPrank(); } function testBatchSafeMint_ShouldRevert_IfCalledNotByMinter() public { @@ -171,11 +164,10 @@ contract UbiquiStickTest is Test { } function testRandom_ShouldReturnRandomValue() public { - vm.warp(1); - vm.difficulty(1); + // by default "block.prevrandao = 0" assertEq( ubiquiStick.exposed_random(), - 12751150048135892262188697730632532742577045435178855596188279334644121003250 + 59314673252666873280629439252894990696031209845167399747113266702537979136323 ); }