Merge pull request #20 from status-im/fix-tests

minAt NOW to avoid failing in next test files
This commit is contained in:
Bitgamma 2020-04-23 14:51:28 +03:00 committed by GitHub
commit 4f9c711678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -33,8 +33,8 @@ library RedeemUtil {
require(_redeem.blockNumber >= (block.number - _maxTxDelayInBlocks), "transaction too old"); require(_redeem.blockNumber >= (block.number - _maxTxDelayInBlocks), "transaction too old");
require(_redeem.blockHash == blockhash(_redeem.blockNumber), "invalid block hash"); require(_redeem.blockHash == blockhash(_redeem.blockNumber), "invalid block hash");
require(block.timestamp < _expirationTime, "expired gift"); require(block.timestamp < _expirationTime, "expired gift");
require(block.timestamp > _startTime, "reedeming not yet started"); require(block.timestamp > _startTime, "reedeming not yet started");
} }
function hashRedeem(Redeem memory _redeem) internal pure returns (bytes32) { function hashRedeem(Redeem memory _redeem) internal pure returns (bytes32) {
@ -79,4 +79,4 @@ library RedeemUtil {
bytes32 codeHash = keccak256(abi.encodePacked(_redeem.code)); bytes32 codeHash = keccak256(abi.encodePacked(_redeem.code));
require(codeHash == _code, "invalid code"); require(codeHash == _code, "invalid code");
} }
} }

View File

@ -361,7 +361,7 @@ contract("GiftBucket", function () {
} catch (e) { } catch (e) {
assert.match(e.message, /invalid block hash/); assert.match(e.message, /invalid block hash/);
} }
}); });
it("can redeem before expiration date", async function() { it("can redeem before expiration date", async function() {
const block = await web3.eth.getBlock("latest"); const block = await web3.eth.getBlock("latest");
@ -398,5 +398,6 @@ contract("GiftBucket", function () {
it("shop can kill contract after expirationTime", async function() { it("shop can kill contract after expirationTime", async function() {
await mineAt(EXPIRATION_TIME); await mineAt(EXPIRATION_TIME);
await testKill(); await testKill();
await mineAt(NOW);
}); });
}); });

View File

@ -205,7 +205,7 @@ contract("NFTBucket", function () {
assert.match(e.message, /only the NFT/); assert.match(e.message, /only the NFT/);
} }
}); });
async function testRedeem(receiver, recipient, signer, relayer, redeemCode, blockNumber, blockHash) { async function testRedeem(receiver, recipient, signer, relayer, redeemCode, blockNumber, blockHash) {
let gift = await NFTBucket.methods.gifts(recipient).call(); let gift = await NFTBucket.methods.gifts(recipient).call();
@ -295,7 +295,7 @@ contract("NFTBucket", function () {
} catch (e) { } catch (e) {
assert.match(e.message, /invalid block hash/); assert.match(e.message, /invalid block hash/);
} }
}); });
it("can redeem before expiration date", async function() { it("can redeem before expiration date", async function() {
const block = await web3.eth.getBlock("latest"); const block = await web3.eth.getBlock("latest");
@ -322,5 +322,6 @@ contract("NFTBucket", function () {
it("shop can kill contract after expirationTime", async function() { it("shop can kill contract after expirationTime", async function() {
await mineAt(EXPIRATION_TIME); await mineAt(EXPIRATION_TIME);
await testKill(); await testKill();
await mineAt(NOW);
}); });
}); });