Add more unit tests for Fraud test
Longer output vector, insufficient value
@@ -392,29 +392,46 @@ contract('DepositFraud', (accounts) => {
it.skip('TODO: full test for startSignerFraudLiquidation', async () => { })
})
- describe('validateRedeemerNotPaid', async () => {
+ // eslint-disable-next-line no-only-tests/no-only-tests
+ describe.only('validateRedeemerNotPaid', async () => {
const _txOutputVector = '0x012040351d0000000016001486e7303082a6a21d5837176bc808bf4828371ab6'
const requesterPKH = '0x86e7303082a6a21d5837176bc808bf4828371ab6'
const prevoutValueBytes = '0xf078351d00000000'
const outpoint = '0x913e39197867de39bff2c93c75173e086388ee7e8707c90ce4a02dd23f7d2c0d00000000'
+ const _longTxOutputVector = `0x034897070000000000220020a4333e5612ab1a1043b25755c89b16d55184a42f81799e623e6bc39db8539c180000000000000000166a14edb1b5c2f39af0fec151732585b1049b078952112040351d0000000016001486e7303082a6a21d5837176bc808bf4828371ab6`
beforeEach(async () => {
await testInstance.setUTXOInfo(prevoutValueBytes, 0, outpoint)
})
- it('returns false if redeemer is payed', async () => {
+ it('returns false if redeemer is payed and value is sufficient', async () => {
await testInstance.setRequestInfo(utils.address0, requesterPKH, 2424, 0, utils.bytes32zero)
const success = await testInstance.validateRedeemerNotPaid(_txOutputVector)
assert.equal(success, false)
})
+ it('returns false if redeemer is payed and value is sufficient (long output vector)', async () => {
+ await testInstance.setRequestInfo(utils.address0, requesterPKH, 2424, 0, utils.bytes32zero)
+
+ const success = await testInstance.validateRedeemerNotPaid(_longTxOutputVector)
+ assert.equal(success, false)
+ })
+
it('returns true if redeemer is not payed', async () => {
await testInstance.setRequestInfo(utils.address0, '0x' + '0'.repeat(20), 2424, 0, utils.bytes32zero)
const success = await testInstance.validateRedeemerNotPaid(_txOutputVector)
assert.equal(success, true)
})
+
+ it('returns true if value is not sufficient', async () => {
+ await testInstance.setRequestInfo(utils.address0, requesterPKH, 2424, 0, utils.bytes32zero)
+ await testInstance.setUTXOInfo('0xf078351d00000001', 0, outpoint)
+
+ const success = await testInstance.validateRedeemerNotPaid(_txOutputVector)
+ assert.equal(success, true)
+ })
})
describe('provideSPVFraudProof', async () => {
