diff --git a/solidity/contracts/deposit/Deposit.sol b/solidity/contracts/deposit/Deposit.sol index 3b5b6f451..ca13f140a 100644 --- a/solidity/contracts/deposit/Deposit.sol +++ b/solidity/contracts/deposit/Deposit.sol @@ -302,49 +302,6 @@ contract Deposit is DepositFactoryAuthority { return true; } - /// @notice Anyone may notify the contract no funding proof was submitted during funding fraud. - /// @dev This is not a funder fault. The signers have faulted, so the funder shouldn't fund. - /// @return True if successful, otherwise revert. - function notifyFraudFundingTimeout() public returns (bool) { - self.notifyFraudFundingTimeout(); - return true; - } - - /// @notice Anyone may notify the deposit of a funding proof during funding fraud. - // We reward the funder the entire bond if this occurs. - /// @dev Takes a pre-parsed transaction and calculates values needed to verify funding. - /// @param _txVersion Transaction version number (4-byte LE). - /// @param _txInputVector All transaction inputs prepended by the number of inputs encoded as a VarInt, max 0xFC(252) inputs. - /// @param _txOutputVector All transaction outputs prepended by the number of outputs encoded as a VarInt, max 0xFC(252) outputs. - /// @param _txLocktime Final 4 bytes of the transaction. - /// @param _fundingOutputIndex Index of funding output in _txOutputVector (0-indexed). - /// @param _merkleProof The merkle proof of transaction inclusion in a block. - /// @param _txIndexInBlock Transaction index in the block (0-indexed). - /// @param _bitcoinHeaders Single bytestring of 80-byte bitcoin headers, lowest height first. - /// @return True if no errors are thrown. - function provideFraudBTCFundingProof( - bytes4 _txVersion, - bytes memory _txInputVector, - bytes memory _txOutputVector, - bytes4 _txLocktime, - uint8 _fundingOutputIndex, - bytes memory _merkleProof, - uint256 _txIndexInBlock, - bytes memory _bitcoinHeaders - ) public returns (bool) { - self.provideFraudBTCFundingProof( - _txVersion, - _txInputVector, - _txOutputVector, - _txLocktime, - _fundingOutputIndex, - _merkleProof, - _txIndexInBlock, - _bitcoinHeaders - ); - return true; - } - /// @notice Anyone may notify the deposit of a funding proof to activate the deposit. /// This is the happy-path of the funding flow. It means that we have succeeded. /// @dev Takes a pre-parsed transaction and calculates values needed to verify funding. diff --git a/solidity/contracts/deposit/DepositFunding.sol b/solidity/contracts/deposit/DepositFunding.sol index cd7a15438..e93add44d 100644 --- a/solidity/contracts/deposit/DepositFunding.sol +++ b/solidity/contracts/deposit/DepositFunding.sol @@ -76,15 +76,6 @@ library DepositFunding { return true; } - /// @notice Slashes the signers partially for committing fraud before funding occurs. - /// @dev Called only by notifyFraudFundingTimeout. - function partiallySlashForFraudInFunding(DepositUtils.Deposit storage _d) internal { - uint256 _seized = _d.seizeSignerBonds(); - uint256 _slash = _seized.div(TBTCConstants.getFundingFraudPartialSlashDivisor()); - _d.pushFundsToKeepGroup(_seized.sub(_slash)); - _d.depositOwner().transfer(_slash); - } - /// @notice Seizes signer bonds and distributes them to the funder. /// @dev This is only called as part of funding fraud flow. function distributeSignerBondsToFunder(DepositUtils.Deposit storage _d) internal { @@ -140,6 +131,7 @@ library DepositFunding { _d.setFailedSetup(); _d.logSetupFailed(); + _d.closeKeep(); fundingTeardown(_d); } @@ -168,84 +160,10 @@ library DepositFunding { bool _isFraud = _d.submitSignatureFraud(_v, _r, _s, _signedDigest, _preimage); require(_isFraud, "Signature is not fraudulent"); _d.logFraudDuringSetup(); - - // If the funding timeout has elapsed, punish the funder too! - if (block.timestamp > _d.fundingProofTimerStart.add(TBTCConstants.getFundingTimeout())) { - _d.setFailedSetup(); - } else { - /* NB: This is reuse of the variable */ - _d.fundingProofTimerStart = block.timestamp; - _d.setFraudAwaitingBTCFundingProof(); - } - } - - /// @notice Anyone may notify the contract no funding proof was submitted during funding fraud. - /// @dev This is not a funder fault. The signers have faulted, so the funder shouldn't fund. - /// @param _d Deposit storage pointer. - function notifyFraudFundingTimeout(DepositUtils.Deposit storage _d) public { - require( - _d.inFraudAwaitingBTCFundingProof(), - "Not currently awaiting fraud-related funding proof" - ); - require( - block.timestamp > _d.fundingProofTimerStart.add(TBTCConstants.getFraudFundingTimeout()), - "Fraud funding proof timeout has not elapsed" - ); - _d.setFailedSetup(); - _d.logSetupFailed(); - - partiallySlashForFraudInFunding(_d); + distributeSignerBondsToFunder(_d); fundingFraudTeardown(_d); - } - - /// @notice Anyone may notify the deposit of a funding proof during funding fraud. - // We reward the funder the entire bond if this occurs. - /// @dev Takes a pre-parsed transaction and calculates values needed to verify funding. - /// @param _d Deposit storage pointer. - /// @param _txVersion Transaction version number (4-byte LE). - /// @param _txInputVector All transaction inputs prepended by the number of inputs encoded as a VarInt, max 0xFC(252) inputs. - /// @param _txOutputVector All transaction outputs prepended by the number of outputs encoded as a VarInt, max 0xFC(252) outputs. - /// @param _txLocktime Final 4 bytes of the transaction. - /// @param _fundingOutputIndex Index of funding output in _txOutputVector (0-indexed). - /// @param _merkleProof The merkle proof of transaction inclusion in a block. - /// @param _txIndexInBlock Transaction index in the block (0-indexed). - /// @param _bitcoinHeaders Single bytestring of 80-byte bitcoin headers, lowest height first. - /// @return True if no errors are thrown. - function provideFraudBTCFundingProof( - DepositUtils.Deposit storage _d, - bytes4 _txVersion, - bytes memory _txInputVector, - bytes memory _txOutputVector, - bytes4 _txLocktime, - uint8 _fundingOutputIndex, - bytes memory _merkleProof, - uint256 _txIndexInBlock, - bytes memory _bitcoinHeaders - ) public returns (bool) { - require(_d.inFraudAwaitingBTCFundingProof(), "Not awaiting a funding proof during setup fraud"); - - bytes8 _valueBytes; - bytes memory _utxoOutpoint; - - (_valueBytes, _utxoOutpoint) = _d.validateAndParseFundingSPVProof( - _txVersion, - _txInputVector, - _txOutputVector, - _txLocktime, - _fundingOutputIndex, - _merkleProof, - _txIndexInBlock, - _bitcoinHeaders - ); - _d.setFailedSetup(); _d.logSetupFailed(); - - // If the proof is accepted, update to failed, and distribute signer bonds - distributeSignerBondsToFunder(_d); - fundingFraudTeardown(_d); - - return true; } /// @notice Anyone may notify the deposit of a funding proof to activate the deposit. diff --git a/solidity/contracts/deposit/DepositLiquidation.sol b/solidity/contracts/deposit/DepositLiquidation.sol index e8331d6c7..8edf1d80e 100644 --- a/solidity/contracts/deposit/DepositLiquidation.sol +++ b/solidity/contracts/deposit/DepositLiquidation.sol @@ -115,7 +115,7 @@ library DepositLiquidation { bytes memory _preimage ) public { require( - !_d.inFunding() && !_d.inFundingFailure(), + !_d.inFunding(), "Use provideFundingECDSAFraudProof instead" ); require( diff --git a/solidity/contracts/deposit/DepositRedemption.sol b/solidity/contracts/deposit/DepositRedemption.sol index dec2b101a..a6b2f6f9b 100644 --- a/solidity/contracts/deposit/DepositRedemption.sol +++ b/solidity/contracts/deposit/DepositRedemption.sol @@ -37,14 +37,6 @@ library DepositRedemption { _keep.distributeERC20Reward(address(_d.tbtcToken), _d.signerFee()); } - /// @notice Closes keep associated with the deposit. - /// @dev Should be called when the keep is no longer needed and the signing - /// group can disband. - function closeKeep(DepositUtils.Deposit storage _d) internal { - IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress); - _keep.closeKeep(); - } - /// @notice Approves digest for signing by a keep. /// @dev Calls given keep to sign the digest. Records a current timestamp /// for given digest. @@ -321,7 +313,7 @@ library DepositRedemption { // Transfer TBTC to signers and close the keep. distributeSignerFee(_d); - closeKeep(_d); + _d.closeKeep(); _d.distributeFeeRebate(); diff --git a/solidity/contracts/deposit/DepositStates.sol b/solidity/contracts/deposit/DepositStates.sol index b2088ae69..84e303db6 100644 --- a/solidity/contracts/deposit/DepositStates.sol +++ b/solidity/contracts/deposit/DepositStates.sol @@ -13,7 +13,6 @@ library DepositStates { AWAITING_BTC_FUNDING_PROOF, // FAILED SETUP - FRAUD_AWAITING_BTC_FUNDING_PROOF, FAILED_SETUP, // ACTIVE @@ -42,14 +41,6 @@ library DepositStates { ); } - /// @notice Check if the contract is currently in the funding faud flow. - /// @dev This checks for the flow, not the SETUP_FAILED termination state. - /// @param _d Deposit storage pointer. - /// @return True if contract is currently in the funding fraud flow else False. - function inFundingFailure(DepositUtils.Deposit storage _d) public view returns (bool) { - return (_d.currentState == uint8(States.FRAUD_AWAITING_BTC_FUNDING_PROOF)); - } - /// @notice Check if the contract is currently in the signer liquidation flow. /// @dev This could be caused by fraud, or by an unfilled margin call. /// @param _d Deposit storage pointer. @@ -111,10 +102,6 @@ library DepositStates { return _d.currentState == uint8(States.AWAITING_BTC_FUNDING_PROOF); } - function inFraudAwaitingBTCFundingProof(DepositUtils.Deposit storage _d) external view returns (bool) { - return _d.currentState == uint8(States.FRAUD_AWAITING_BTC_FUNDING_PROOF); - } - function inFailedSetup(DepositUtils.Deposit storage _d) external view returns (bool) { return _d.currentState == uint8(States.FAILED_SETUP); } @@ -159,10 +146,6 @@ library DepositStates { _d.currentState = uint8(States.AWAITING_BTC_FUNDING_PROOF); } - function setFraudAwaitingBTCFundingProof(DepositUtils.Deposit storage _d) external { - _d.currentState = uint8(States.FRAUD_AWAITING_BTC_FUNDING_PROOF); - } - function setFailedSetup(DepositUtils.Deposit storage _d) external { _d.currentState = uint8(States.FAILED_SETUP); } diff --git a/solidity/contracts/deposit/DepositUtils.sol b/solidity/contracts/deposit/DepositUtils.sol index e4cc46307..f13dcd609 100644 --- a/solidity/contracts/deposit/DepositUtils.sol +++ b/solidity/contracts/deposit/DepositUtils.sol @@ -70,6 +70,14 @@ library DepositUtils { mapping (bytes32 => uint256) approvedDigests; } + /// @notice Closes keep associated with the deposit. + /// @dev Should be called when the keep is no longer needed and the signing + /// group can disband. + function closeKeep(DepositUtils.Deposit storage _d) internal { + IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress); + _keep.closeKeep(); + } + /// @notice Gets the current block difficulty. /// @dev Calls the light relay and gets the current block difficulty. /// @return The difficulty. diff --git a/solidity/test/DepositFraudTest.js b/solidity/test/DepositFraudTest.js index 7513849ba..a3bb702ea 100644 --- a/solidity/test/DepositFraudTest.js +++ b/solidity/test/DepositFraudTest.js @@ -8,39 +8,19 @@ const {BN, constants, expectRevert} = require("@openzeppelin/test-helpers") const {ZERO_ADDRESS} = constants const {expect} = require("chai") -const currentDifficulty = 6353030562983 -const _version = "0x01000000" -const _txInputVector = `0x01913e39197867de39bff2c93c75173e086388ee7e8707c90ce4a02dd23f7d2c0d0000000000ffffffff` -const _txOutputVector = - "0x012040351d0000000016001486e7303082a6a21d5837176bc808bf4828371ab6" -const _fundingOutputIndex = 0 -const _txLocktime = "0x4ec10800" -const _txIndexInBlock = 129 -const _bitcoinHeaders = - "0x00e0ff3fd877ad23af1d0d3e0eb6a700d85b692975dacd36e47b1b00000000000000000095ba61df5961d7fa0a45cd7467e11f20932c7a0b74c59318e86581c6b509554876f6c65c114e2c17e42524d300000020994d3802da5adf80345261bcff2eb87ab7b70db786cb0000000000000000000003169efc259f6e4b5e1bfa469f06792d6f07976a098bff2940c8e7ed3105fdc5eff7c65c114e2c170c4dffc30000c020f898b7ea6a405728055b0627f53f42c57290fe78e0b91900000000000000000075472c91a94fa2aab73369c0686a58796949cf60976e530f6eb295320fa15a1b77f8c65c114e2c17387f1df00000002069137421fc274aa2c907dbf0ec4754285897e8aa36332b0000000000000000004308f2494b702c40e9d61991feb7a15b3be1d73ce988e354e52e7a4e611bd9c2a2f8c65c114e2c1740287df200000020ab63607b09395f856adaa69d553755d9ba5bd8d15da20a000000000000000000090ea7559cda848d97575cb9696c8e33ba7f38d18d5e2f8422837c354aec147839fbc65c114e2c175cf077d6000000200ab3612eac08a31a8fb1d9b5397f897db8d26f6cd83a230000000000000000006f4888720ecbf980ff9c983a8e2e60ad329cc7b130916c2bf2300ea54e412a9ed6fcc65c114e2c17d4fbb88500000020d3e51560f77628a26a8fad01c88f98bd6c9e4bc8703b180000000000000000008e2c6e62a1f4d45dd03be1e6692df89a4e3b1223a4dbdfa94cca94c04c22049992fdc65c114e2c17463edb5e" -const _signerPubkeyX = - "0xd4aee75e57179f7cd18adcbaa7e2fca4ff7b1b446df88bf0b4398e4a26965a6e" -const _signerPubkeyY = - "0xe8bfb23428a4efecb3ebdc636139de9a568ed427fff20d28baa33ed48e9c44e1" -const _merkleProof = - "0x886f7da48f4ccfe49283c678dedb376c89853ba46d9a297fe39e8dd557d1f8deb0fb1a28c03f71b267f3a33459b2566975b1653a1238947ed05edca17ef64181b1f09d858a6e25bae4b0e245993d4ea77facba8ed0371bb9b8a6724475bcdc9edf9ead30b61cf6714758b7c93d1b725f86c2a66a07dd291ef566eaa5a59516823d57fd50557f1d938cc2fb61fe0e1acee6f9cb618a9210688a2965c52feabee66d660a5e7f158e363dc464fca2bb1cc856173366d5d20b5cd513a3aab8ebc5be2bd196b783b8773af2472abcea3e32e97938283f7b454769aa1c064c311c3342a755029ee338664999bd8d432080eafae3ca86b52ad2e321e9e634a46c1bd0d174e38bcd4c59a0f0a78c5906c015ef4daf6beb0500a59f4cae00cd46069ce60db2182e74561028e4462f59f639c89b8e254602d6ad9c212b7c2af5db9275e48c467539c6af678d6f09214182df848bd79a06df706f7c3fddfdd95e6f27326c6217ee446543a443f82b711f48c173a769ae8d1e92a986bc76fca732f088bbe049" - describe("DepositFraud", async function() { let tbtcConstants - let mockRelay let tbtcSystemStub let tbtcDepositToken let testDeposit let ecdsaKeepStub let beneficiary - let fundingProofTimerStart let assertBalance before(async () => { ;({ tbtcConstants, tbtcToken, - mockRelay, tbtcSystemStub, tbtcDepositToken, testDeposit, @@ -62,26 +42,21 @@ describe("DepositFraud", async function() { }) describe("provideFundingECDSAFraudProof", async () => { - let timer + const bond = 1000 before(async () => { timer = await tbtcConstants.getFundingTimeout.call() }) beforeEach(async () => { - 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}) + await ecdsaKeepStub.send(bond, {from: owner}) }) - it("updates to awaiting fraud funding proof and logs FraudDuringSetup if the timer has not elapsed", async () => { + it("updates to awaiting fraud funding proof, distributes signer bond to funder, and logs FraudDuringSetup", async () => { const blockNumber = await web3.eth.getBlock("latest").number - - await testDeposit.setFundingProofTimerStart(fundingProofTimerStart * 5) // timer has not elapsed + const initialBalance = await web3.eth.getBalance(beneficiary) await testDeposit.provideFundingECDSAFraudProof( 0, @@ -91,30 +66,11 @@ describe("DepositFraud", async function() { "0x00", ) - const depositState = await testDeposit.getState.call() - expect(depositState).to.eq.BN(states.FRAUD_AWAITING_BTC_FUNDING_PROOF) - - const actualFundingProofTimerStart = await testDeposit.getFundingProofTimerStart.call() - expect( - actualFundingProofTimerStart, - "fundingProofTimerStart did not increase", - ).to.be.bignumber.greaterThan(new BN(fundingProofTimerStart)) - - const eventList = await tbtcSystemStub.getPastEvents("FraudDuringSetup", { - fromBlock: blockNumber, - toBlock: "latest", - }) - expect(eventList.length, "bad event length").to.equal(1) - }) + await assertBalance.eth(ecdsaKeepStub.address, new BN(0)) - it("updates to failed, logs FraudDuringSetup, and burns value if the timer has elapsed", async () => { - const blockNumber = await web3.eth.getBlock("latest").number - await testDeposit.provideFundingECDSAFraudProof( - 0, - bytes32zero, - bytes32zero, - bytes32zero, - "0x00", + await assertBalance.eth( + beneficiary, + new BN(initialBalance).add(new BN(bond)), ) const depositState = await testDeposit.getState.call() @@ -158,190 +114,6 @@ describe("DepositFraud", async function() { }) }) - describe("notifyFraudFundingTimeout", async () => { - let timer - - before(async () => { - timer = await tbtcConstants.getFraudFundingTimeout.call() - }) - - beforeEach(async () => { - const block = await web3.eth.getBlock("latest") - const blockTimestamp = block.timestamp - fundingProofTimerStart = blockTimestamp - timer.toNumber() - 1 // timer has elapsed - - await testDeposit.setState(states.FRAUD_AWAITING_BTC_FUNDING_PROOF) - await testDeposit.setFundingProofTimerStart(fundingProofTimerStart) - - await ecdsaKeepStub.send(1000000, {from: owner}) - }) - - it("updates state to setup failed, logs SetupFailed, and deconstes state", async () => { - const blockNumber = await web3.eth.getBlock("latest").number - - await testDeposit.notifyFraudFundingTimeout() - - const keepAddress = await testDeposit.getKeepAddress.call() - expect(keepAddress, "Keep address not deconsted").to.equal(ZERO_ADDRESS) - - const signingGroupRequestedAt = await testDeposit.getSigningGroupRequestedAt.call() - expect( - signingGroupRequestedAt, - "signingGroupRequestedAt not deconsted", - ).to.be.bignumber.equal(new BN(0)) - - const fundingProofTimerStart = await testDeposit.getFundingProofTimerStart.call() - expect( - fundingProofTimerStart, - "fundingProofTimerStart not deconsted", - ).to.be.bignumber.equal(new BN(0)) - - const signingGroupPublicKey = await testDeposit.getSigningGroupPublicKey.call() - expect(signingGroupPublicKey[0]).to.equal(bytes32zero) // pubkey X - expect(signingGroupPublicKey[1]).to.equal(bytes32zero) // pubkey Y - - const depositState = await testDeposit.getState.call() - expect(depositState).to.eq.BN(states.FAILED_SETUP) - - const eventList = await tbtcSystemStub.getPastEvents("SetupFailed", { - fromBlock: blockNumber, - toBlock: "latest", - }) - expect(eventList.length).to.equal(1) - }) - - it("reverts if not awaiting fraud funding proof", async () => { - await testDeposit.setState(states.START) - - await expectRevert( - testDeposit.notifyFraudFundingTimeout(), - "Not currently awaiting fraud-related funding proof", - ) - }) - - it("reverts if the timer has not elapsed", async () => { - await testDeposit.setFundingProofTimerStart(fundingProofTimerStart * 5) - - await expectRevert( - testDeposit.notifyFraudFundingTimeout(), - "Fraud funding proof timeout has not elapsed", - ) - }) - - it("asserts that it partially slashes signers", async () => { - const initialBalance = await web3.eth.getBalance(beneficiary) - const toSeize = await web3.eth.getBalance(ecdsaKeepStub.address) - - await testDeposit.setFundingProofTimerStart(fundingProofTimerStart) - - await testDeposit.notifyFraudFundingTimeout() - - const divisor = await tbtcConstants.getFundingFraudPartialSlashDivisor.call() - const slash = new BN(toSeize).div(new BN(divisor)) - const balanceAfter = await web3.eth.getBalance(beneficiary) - const balanceCheck = new BN(initialBalance).add(slash) - - expect( - balanceCheck, - "partial slash not correctly awarded to funder", - ).to.eq.BN(balanceAfter) - }) - }) - - describe("provideFraudBTCFundingProof", async () => { - beforeEach(async () => { - await testDeposit.setSigningGroupPublicKey(_signerPubkeyX, _signerPubkeyY) - await mockRelay.setCurrentEpochDifficulty(currentDifficulty) - await testDeposit.setState(states.FRAUD_AWAITING_BTC_FUNDING_PROOF) - await ecdsaKeepStub.send(1000000, {from: owner}) - }) - - it("updates to setup failed, logs SetupFailed, ", async () => { - const blockNumber = await web3.eth.getBlock("latest").number - - await testDeposit.provideFraudBTCFundingProof( - _version, - _txInputVector, - _txOutputVector, - _txLocktime, - _fundingOutputIndex, - _merkleProof, - _txIndexInBlock, - _bitcoinHeaders, - ) - - const keepAddress = await testDeposit.getKeepAddress.call() - expect(keepAddress, "Keep address not deconsted").to.equal(ZERO_ADDRESS) - - const signingGroupRequestedAt = await testDeposit.getSigningGroupRequestedAt.call() - expect( - signingGroupRequestedAt, - "signingGroupRequestedAt not deconsted", - ).to.not.equal(0) - - const fundingProofTimerStart = await testDeposit.getFundingProofTimerStart.call() - expect( - fundingProofTimerStart, - "fundingProofTimerStart not deconsted", - ).to.not.equal(0) - - const signingGroupPublicKey = await testDeposit.getSigningGroupPublicKey.call() - expect(signingGroupPublicKey[0]).to.equal(bytes32zero) // pubkey X - expect(signingGroupPublicKey[1]).to.equal(bytes32zero) // pubkey Y - - const depostState = await testDeposit.getState.call() - expect(depostState).to.eq.BN(states.FAILED_SETUP) - - const eventList = await tbtcSystemStub.getPastEvents("SetupFailed", { - fromBlock: blockNumber, - toBlock: "latest", - }) - expect(eventList.length).to.equal(1) - }) - - it("reverts if not awaiting a funding proof during setup fraud", async () => { - await testDeposit.setState(states.START) - - await expectRevert( - testDeposit.provideFraudBTCFundingProof( - _version, - _txInputVector, - _txOutputVector, - _txLocktime, - _fundingOutputIndex, - _merkleProof, - _txIndexInBlock, - _bitcoinHeaders, - ), - "Not awaiting a funding proof during setup fraud", - ) - }) - - it("assert distribute signer bonds to funder", async () => { - const initialBalance = await web3.eth.getBalance(beneficiary) - const signerBond = await web3.eth.getBalance(ecdsaKeepStub.address) - - await testDeposit.provideFraudBTCFundingProof( - _version, - _txInputVector, - _txOutputVector, - _txLocktime, - _fundingOutputIndex, - _merkleProof, - _txIndexInBlock, - _bitcoinHeaders, - ) - - const balanceAfter = await web3.eth.getBalance(beneficiary) - const balanceCheck = new BN(initialBalance).add(new BN(signerBond)) - - expect( - balanceCheck, - "partial slash not correctly awarded to funder", - ).to.eq.BN(balanceAfter) - }) - }) - describe("startSignerFraudLiquidation", async () => { let signerBond before(async () => { @@ -382,6 +154,7 @@ describe("DepositFraud", async function() { // setting redeemer address suggests we are coming from redemption flow testDeposit.setRedeemerAddress(owner) + const currentBond = await web3.eth.getBalance(ecdsaKeepStub.address) const block = await web3.eth.getBlock("latest") const initialBalance = await web3.eth.getBalance(owner) await testDeposit.startSignerFraudLiquidation() @@ -393,7 +166,7 @@ describe("DepositFraud", async function() { await assertBalance.eth( owner, - new BN(initialBalance).add(new BN(signerBond)), + new BN(initialBalance).add(new BN(currentBond)), ) expect(events[0].returnValues[0]).to.equal(testDeposit.address) diff --git a/solidity/test/helpers/utils.js b/solidity/test/helpers/utils.js index 45d6d9408..5f95cd003 100644 --- a/solidity/test/helpers/utils.js +++ b/solidity/test/helpers/utils.js @@ -14,16 +14,15 @@ const states = { START: new BN(0), AWAITING_SIGNER_SETUP: new BN(1), AWAITING_BTC_FUNDING_PROOF: new BN(2), - FRAUD_AWAITING_BTC_FUNDING_PROOF: new BN(3), - FAILED_SETUP: new BN(4), - ACTIVE: new BN(5), - AWAITING_WITHDRAWAL_SIGNATURE: new BN(6), - AWAITING_WITHDRAWAL_PROOF: new BN(7), - REDEEMED: new BN(8), - COURTESY_CALL: new BN(9), - FRAUD_LIQUIDATION_IN_PROGRESS: new BN(10), - LIQUIDATION_IN_PROGRESS: new BN(11), - LIQUIDATED: new BN(12), + FAILED_SETUP: new BN(3), + ACTIVE: new BN(4), + AWAITING_WITHDRAWAL_SIGNATURE: new BN(5), + AWAITING_WITHDRAWAL_PROOF: new BN(6), + REDEEMED: new BN(7), + COURTESY_CALL: new BN(8), + FRAUD_LIQUIDATION_IN_PROGRESS: new BN(9), + LIQUIDATION_IN_PROGRESS: new BN(10), + LIQUIDATED: new BN(11), } function hash160(hexString) {