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

Commit

Permalink
Update tests and test contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuba committed Aug 30, 2019
1 parent 325692e commit 2431a7f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
11 changes: 0 additions & 11 deletions implementation/test/KeepBridgeTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,4 @@ contract('KeepBridge', (accounts) => {
)
})
})

describe('requestNewKeep()', async () => {
it('sends caller as owner to open new keep', async () => {
const expectedKeepOwner = accounts[2]

await keepBridge.requestNewKeep(5, 10, { from: expectedKeepOwner })
const keepOwner = await ecdsaKeepVendor.keepOwner.call()

assert.equal(expectedKeepOwner, keepOwner, 'incorrect keep owner address')
})
})
})
37 changes: 37 additions & 0 deletions implementation/test/TBTCSystemTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const TBTCSystem = artifacts.require('TBTCSystem')
const KeepRegistryStub = artifacts.require('KeepRegistryStub')
const ECDSAKeepVendorStub = artifacts.require('ECDSAKeepVendorStub')

contract('TBTCSystem', (accounts) => {
let tbtcSystem
let ecdsaKeepVendor

before(async () => {
ecdsaKeepVendor = await ECDSAKeepVendorStub.new()

const keepRegistry = await KeepRegistryStub.new()
await keepRegistry.setVendor(ecdsaKeepVendor.address)

tbtcSystem = await TBTCSystem.deployed()
await tbtcSystem.initialize(keepRegistry.address)
})

describe('requestNewKeep()', async () => {
it('sends caller as owner to open new keep', async () => {
const expectedKeepOwner = accounts[2]

await tbtcSystem.requestNewKeep(5, 10, { from: expectedKeepOwner })
const keepOwner = await ecdsaKeepVendor.keepOwner.call()

assert.equal(expectedKeepOwner, keepOwner, 'incorrect keep owner address')
})

it('returns keep address', async () => {
const expectedKeepAddress = '0x0000000000000000000000000000000000000378'

const result = await tbtcSystem.requestNewKeep.call(5, 10)

assert.equal(expectedKeepAddress, result, 'incorrect keep address')
})
})
})
5 changes: 0 additions & 5 deletions implementation/test/contracts/deposit/KeepStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ contract KeepStub {
return success;
}

function requestNewKeep(uint256 _m, uint256 _n) external payable returns (address _keepAddress) {
_m; _n;
return keepAddress;
}

function getKeepPubkey(address _keepAddress) external view returns (bytes memory) {
_keepAddress; success;
// this is the pubkey coresponding to 32 '11' bytes
Expand Down
6 changes: 6 additions & 0 deletions implementation/test/contracts/deposit/TBTCSystemStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.5.10;
import {TBTCSystem} from '../../../contracts/system/TBTCSystem.sol';

contract TBTCSystemStub is TBTCSystem {
address keepAddress = address(7);

function setOraclePrice(uint256 _oraclePrice) external {
oraclePrice = _oraclePrice;
Expand All @@ -20,4 +21,9 @@ contract TBTCSystemStub is TBTCSystem {
function approvedToLog(address _caller) public view returns (bool) {
_caller; return true;
}

function requestNewKeep(uint256 _m, uint256 _n) external payable returns (address _keepAddress) {
_m; _n;
return keepAddress;
}
}
1 change: 1 addition & 0 deletions implementation/test/contracts/keep/ECDSAKeepVendorStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ contract ECDSAKeepVendorStub is ECDSAKeepVendor {
address _owner
) external payable returns (address _keepAddress) {
keepOwner = _owner;
_keepAddress = address(888);
}
}

0 comments on commit 2431a7f

Please sign in to comment.