Fix signature bouncer tests.
This commit is contained in:
@ -26,7 +26,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
describe('modifiers', function () {
|
||||
context('plain signature', function () {
|
||||
it('allows valid signature for sender', async function () {
|
||||
await this.sigBouncer.onlyWithValidSignature(this.signFor(authorizedUser), { from: authorizedUser });
|
||||
await this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser), { from: authorizedUser });
|
||||
});
|
||||
|
||||
it('does not allow invalid signature for sender', async function () {
|
||||
@ -37,13 +37,13 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
|
||||
it('does not allow valid signature for other sender', async function () {
|
||||
await shouldFail.reverting(
|
||||
this.sigBouncer.onlyWithValidSignature(this.signFor(authorizedUser), { from: anyone })
|
||||
this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser), { from: anyone })
|
||||
);
|
||||
});
|
||||
|
||||
it('does not allow valid signature for method for sender', async function () {
|
||||
await shouldFail.reverting(
|
||||
this.sigBouncer.onlyWithValidSignature(this.signFor(authorizedUser, 'onlyWithValidSignature'),
|
||||
this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser, 'onlyWithValidSignature'),
|
||||
{ from: authorizedUser })
|
||||
);
|
||||
});
|
||||
@ -52,7 +52,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
context('method signature', function () {
|
||||
it('allows valid signature with correct method for sender', async function () {
|
||||
await this.sigBouncer.onlyWithValidSignatureAndMethod(
|
||||
this.signFor(authorizedUser, 'onlyWithValidSignatureAndMethod'), { from: authorizedUser }
|
||||
await this.signFor(authorizedUser, 'onlyWithValidSignatureAndMethod'), { from: authorizedUser }
|
||||
);
|
||||
});
|
||||
|
||||
@ -65,21 +65,21 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
it('does not allow valid signature with correct method for other sender', async function () {
|
||||
await shouldFail.reverting(
|
||||
this.sigBouncer.onlyWithValidSignatureAndMethod(
|
||||
this.signFor(authorizedUser, 'onlyWithValidSignatureAndMethod'), { from: anyone }
|
||||
await this.signFor(authorizedUser, 'onlyWithValidSignatureAndMethod'), { from: anyone }
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('does not allow valid method signature with incorrect method for sender', async function () {
|
||||
await shouldFail.reverting(
|
||||
this.sigBouncer.onlyWithValidSignatureAndMethod(this.signFor(authorizedUser, 'theWrongMethod'),
|
||||
this.sigBouncer.onlyWithValidSignatureAndMethod(await this.signFor(authorizedUser, 'theWrongMethod'),
|
||||
{ from: authorizedUser })
|
||||
);
|
||||
});
|
||||
|
||||
it('does not allow valid non-method signature method for sender', async function () {
|
||||
await shouldFail.reverting(
|
||||
this.sigBouncer.onlyWithValidSignatureAndMethod(this.signFor(authorizedUser), { from: authorizedUser })
|
||||
this.sigBouncer.onlyWithValidSignatureAndMethod(await this.signFor(authorizedUser), { from: authorizedUser })
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -87,7 +87,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
context('method and data signature', function () {
|
||||
it('allows valid signature with correct method and data for sender', async function () {
|
||||
await this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE,
|
||||
this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]), { from: authorizedUser }
|
||||
await this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]), { from: authorizedUser }
|
||||
);
|
||||
});
|
||||
|
||||
@ -100,7 +100,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
it('does not allow valid signature with correct method and incorrect data for sender', async function () {
|
||||
await shouldFail.reverting(
|
||||
this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE + 10,
|
||||
this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]),
|
||||
await this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]),
|
||||
{ from: authorizedUser }
|
||||
)
|
||||
);
|
||||
@ -109,7 +109,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
it('does not allow valid signature with correct method and data for other sender', async function () {
|
||||
await shouldFail.reverting(
|
||||
this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE,
|
||||
this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]),
|
||||
await this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]),
|
||||
{ from: anyone }
|
||||
)
|
||||
);
|
||||
@ -118,7 +118,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
it('does not allow valid non-method signature for sender', async function () {
|
||||
await shouldFail.reverting(
|
||||
this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE,
|
||||
this.signFor(authorizedUser), { from: authorizedUser }
|
||||
await this.signFor(authorizedUser), { from: authorizedUser }
|
||||
)
|
||||
);
|
||||
});
|
||||
@ -134,7 +134,8 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
context('signature validation', function () {
|
||||
context('plain signature', function () {
|
||||
it('validates valid signature for valid user', async function () {
|
||||
(await this.sigBouncer.checkValidSignature(authorizedUser, this.signFor(authorizedUser))).should.equal(true);
|
||||
(await this.sigBouncer.checkValidSignature(authorizedUser, await this.signFor(authorizedUser)))
|
||||
.should.equal(true);
|
||||
});
|
||||
|
||||
it('does not validate invalid signature for valid user', async function () {
|
||||
@ -142,11 +143,12 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
});
|
||||
|
||||
it('does not validate valid signature for anyone', async function () {
|
||||
(await this.sigBouncer.checkValidSignature(anyone, this.signFor(authorizedUser))).should.equal(false);
|
||||
(await this.sigBouncer.checkValidSignature(anyone, await this.signFor(authorizedUser))).should.equal(false);
|
||||
});
|
||||
|
||||
it('does not validate valid signature for method for valid user', async function () {
|
||||
(await this.sigBouncer.checkValidSignature(authorizedUser, this.signFor(authorizedUser, 'checkValidSignature'))
|
||||
(await this.sigBouncer.checkValidSignature(
|
||||
authorizedUser, await this.signFor(authorizedUser, 'checkValidSignature'))
|
||||
).should.equal(false);
|
||||
});
|
||||
});
|
||||
@ -154,7 +156,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
context('method signature', function () {
|
||||
it('validates valid signature with correct method for valid user', async function () {
|
||||
(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser,
|
||||
this.signFor(authorizedUser, 'checkValidSignatureAndMethod'))
|
||||
await this.signFor(authorizedUser, 'checkValidSignatureAndMethod'))
|
||||
).should.equal(true);
|
||||
});
|
||||
|
||||
@ -164,12 +166,12 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
|
||||
it('does not validate valid signature with correct method for anyone', async function () {
|
||||
(await this.sigBouncer.checkValidSignatureAndMethod(anyone,
|
||||
this.signFor(authorizedUser, 'checkValidSignatureAndMethod'))
|
||||
await this.signFor(authorizedUser, 'checkValidSignatureAndMethod'))
|
||||
).should.equal(false);
|
||||
});
|
||||
|
||||
it('does not validate valid non-method signature with correct method for valid user', async function () {
|
||||
(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, this.signFor(authorizedUser))
|
||||
(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, await this.signFor(authorizedUser))
|
||||
).should.equal(false);
|
||||
});
|
||||
});
|
||||
@ -177,7 +179,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
context('method and data signature', function () {
|
||||
it('validates valid signature with correct method and data for valid user', async function () {
|
||||
(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE,
|
||||
this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
|
||||
await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
|
||||
).should.equal(true);
|
||||
});
|
||||
|
||||
@ -189,21 +191,21 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
|
||||
it('does not validate valid signature with correct method and incorrect data for valid user',
|
||||
async function () {
|
||||
(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE + 10,
|
||||
this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
|
||||
await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
|
||||
).should.equal(false);
|
||||
}
|
||||
);
|
||||
|
||||
it('does not validate valid signature with correct method and data for anyone', async function () {
|
||||
(await this.sigBouncer.checkValidSignatureAndData(anyone, BYTES_VALUE, UINT_VALUE,
|
||||
this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
|
||||
await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
|
||||
).should.equal(false);
|
||||
});
|
||||
|
||||
it('does not validate valid non-method-data signature with correct method and data for valid user',
|
||||
async function () {
|
||||
(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE,
|
||||
this.signFor(authorizedUser, 'checkValidSignatureAndData'))
|
||||
await this.signFor(authorizedUser, 'checkValidSignatureAndData'))
|
||||
).should.equal(false);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user