Skip to content

Commit

Permalink
full allowance
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Sep 13, 2023
1 parent edd2763 commit 5d13586
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion contracts/test/TestTokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('TestTokens', function () {
expect(await TestTokens.read.decimals()).to.equal(18);
});

it.only('TestTokens should let me approve allowances via Permit style signatures', async function () {
it('TestTokens should let me approve allowances via Permit style signatures', async function () {
const {TestTokens, TestTokensPermitSigner, tokensBeneficiary, otherAccounts} = await loadFixture(
deployStratagemsWithDefaultConfig,
);
Expand All @@ -88,5 +88,28 @@ describe('TestTokens', function () {
const allowance = await TestTokens.read.allowance([owner, spender]);
expect(allowance).to.equal(value);
});

it('TestTokens should let me approve total allowance via Permit style signatures', async function () {
const {TestTokens, TestTokensPermitSigner, tokensBeneficiary, otherAccounts} = await loadFixture(
deployStratagemsWithDefaultConfig,
);
const owner = tokensBeneficiary;
const spender = otherAccounts[2];
const value = BigInt('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
const nonce = 0;
const deadline = 0;
const signature = await TestTokensPermitSigner.sign(tokensBeneficiary, {
owner,
spender,
value: value.toString(),
nonce,
deadline,
});
const {v, r, s} = hexToSignature(signature);
await TestTokens.write.permit([owner, spender, value, BigInt(deadline), Number(v), r, s], {account: spender});
await TestTokens.write.transferFrom([owner, spender, parseEther('1')], {account: spender});
const allowance = await TestTokens.read.allowance([owner, spender]);
expect(allowance).to.equal(value);
});
});
});

0 comments on commit 5d13586

Please sign in to comment.