Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Keep stub default success and reset function
Browse files Browse the repository at this point in the history
We set default value for success in ECDSAKeepStub to be true and
added reset value used in before tests blocks to set it back to default
value.

We removed redundant `setSussess(true)` calls, we no longer need them as
we reset it.
  • Loading branch information
nkuba committed Mar 24, 2020
1 parent c092693 commit b77f589
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
4 changes: 4 additions & 0 deletions implementation/contracts/test/keep/ECDSAKeepStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ contract ECDSAKeepStub is IBondedECDSAKeep {

// Functions to set data for tests.

function reset() public {
success = true;
}

function setPublicKey(bytes memory _publicKey) public {
publicKey = _publicKey;
}
Expand Down
5 changes: 2 additions & 3 deletions implementation/test/DepositFraudTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("DepositFraud", async function() {
const block = await web3.eth.getBlock("latest")
const blockTimestamp = block.timestamp
fundingProofTimerStart = blockTimestamp - timer.toNumber() - 1 // has elapsed
await ecdsaKeepStub.setSuccess(true)

await testDeposit.setState(states.AWAITING_BTC_FUNDING_PROOF)

await ecdsaKeepStub.send(1000000, {from: owner})
Expand Down Expand Up @@ -441,8 +441,7 @@ describe("DepositFraud", async function() {
describe("provideECDSAFraudProof", async () => {
before(async () => {
await testDeposit.setState(states.ACTIVE)
await ecdsaKeepStub.send(1000000, {from: owner})
await ecdsaKeepStub.setSuccess(true)
await ecdsaKeepStub.send(1000000, { from: owner })
})

beforeEach(async () => {
Expand Down
2 changes: 0 additions & 2 deletions implementation/test/DepositRedemptionTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ describe("DepositRedemption", async function() {
await tbtcToken.resetAllowance(testDeposit.address, requiredBalance, {
from: owner,
})
await ecdsaKeepStub.setSuccess(true)
})

afterEach(async () => {
Expand Down Expand Up @@ -797,7 +796,6 @@ describe("DepositRedemption", async function() {
withdrawalRequestTime,
prevSighash,
)
await ecdsaKeepStub.setSuccess(true)
})

it("approves a new digest for signing, updates the state, and logs RedemptionRequested", async () => {
Expand Down
25 changes: 11 additions & 14 deletions implementation/test/VendingMachineTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe("VendingMachine", async function() {
let tbtcDepositToken
let feeRebateToken
let testDeposit
let ecdsaKeepStub

let assertBalance
let tdtId
Expand All @@ -47,18 +46,17 @@ describe("VendingMachine", async function() {

before(async () => {
let deployed
;({
mockRelay,
tbtcSystemStub,
tbtcToken,
tbtcDepositToken,
feeRebateToken,
testDeposit,
ecdsaKeepStub,
deployed,
redemptionScript,
fundingScript,
} = await deployAndLinkAll())
; ({
mockRelay,
tbtcSystemStub,
tbtcToken,
tbtcDepositToken,
feeRebateToken,
testDeposit,
deployed,
redemptionScript,
fundingScript,
} = await deployAndLinkAll())
vendingMachine = deployed.VendingMachine

assertBalance = new AssertBalance(tbtcToken)
Expand Down Expand Up @@ -337,7 +335,6 @@ describe("VendingMachine", async function() {
await tbtcToken.resetAllowance(vendingMachine.address, requiredBalance, {
from: owner,
})
await ecdsaKeepStub.setSuccess(true)
await testDeposit.setState(states.ACTIVE)
await testDeposit.setUTXOInfo(valueBytes, block.timestamp, outpoint)
})
Expand Down

0 comments on commit b77f589

Please sign in to comment.