Skip to content

Commit

Permalink
Update mockOVM_BondManager to be sequencer-only (#146)
Browse files Browse the repository at this point in the history
* update function, add test

* linting

* more lint
  • Loading branch information
ben-chain authored Dec 15, 2020
1 parent ab4dad2 commit 121bae7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ pragma solidity ^0.7.0;
/* Interface Imports */
import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol";

/* Contract Imports */
import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol";

/**
* @title mockOVM_BondManager
*/
contract mockOVM_BondManager is iOVM_BondManager {
contract mockOVM_BondManager is iOVM_BondManager, Lib_AddressResolver {
constructor(
address _libAddressManager
)
Lib_AddressResolver(_libAddressManager)
{}

function recordGasSpent(
bytes32 _preStateRoot,
bytes32 _txHash,
Expand Down Expand Up @@ -59,7 +68,8 @@ contract mockOVM_BondManager is iOVM_BondManager {
bool
)
{
return true;
// Only authenticate sequencer to submit state root batches.
return _who == resolve("OVM_Sequencer");
}

function getGasSpent(
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/src/contract-deployment/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export const makeContractDeployConfig = async (
},
OVM_BondManager: {
factory: getContractFactory('mockOVM_BondManager'),
params: [AddressManager.address],
},
OVM_ETH: {
factory: getContractFactory('OVM_ETH'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { expect } from '../../../setup'

/* External Imports */
import { ethers } from '@nomiclabs/buidler'
import { Signer, Contract } from 'ethers'

/* Internal Imports */
import { makeAddressManager } from '../../../helpers'

describe('mockOVM_BondManager', () => {
let sequencer: Signer
let nonSequencer: Signer
before(async () => {
;[sequencer, nonSequencer] = await ethers.getSigners()
})

let AddressManager: Contract
before(async () => {
AddressManager = await makeAddressManager()
})

let mockOVM_BondManager: Contract
before(async () => {
mockOVM_BondManager = await (
await ethers.getContractFactory('mockOVM_BondManager')
).deploy(AddressManager.address)

AddressManager.setAddress('OVM_Sequencer', await sequencer.getAddress())
})

describe('isCollateralized', () => {
it('should return true for OVM_Sequencer', async () => {
expect(
await mockOVM_BondManager.isCollateralized(await sequencer.getAddress())
).to.equal(true)
})

it('should return false for non-sequencer', async () => {
expect(
await mockOVM_BondManager.isCollateralized(
await nonSequencer.getAddress()
)
).to.equal(false)
})
})
})

0 comments on commit 121bae7

Please sign in to comment.