Skip to content

Commit

Permalink
style: run lint:fix on all code
Browse files Browse the repository at this point in the history
  • Loading branch information
snario committed Jun 29, 2021
1 parent 35c846a commit 305fff2
Show file tree
Hide file tree
Showing 43 changed files with 474 additions and 613 deletions.
3 changes: 2 additions & 1 deletion integration-tests/sync-tests/1-sync-verifier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ describe('Syncing a verifier', () => {
})

it('should sync dummy transaction', async () => {
const totalElementsBefore = (await env.ctc.getTotalElements()) as BigNumber
const totalElementsBefore =
(await env.ctc.getTotalElements()) as BigNumber

const tx = {
to: '0x' + '1234'.repeat(10),
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/test/basic-l1-l2-communication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ describe('Basic L1<>L2 Communication', async () => {
// This call is fine but will give a status of 0.
const transaction = await env.l1Messenger.sendMessage(
predeploys.Lib_AddressManager,
getContractInterface(
'Lib_AddressManager'
).encodeFunctionData('getAddress', ['whatever']),
getContractInterface('Lib_AddressManager').encodeFunctionData(
'getAddress',
['whatever']
),
5000000
)

Expand Down
6 changes: 4 additions & 2 deletions integration-tests/test/fee-payment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ describe('Fee Payment Integration Tests', async () => {
other,
utils.parseEther('0.5')
)
const executionGas = await (env.ovmEth
.provider as any).send('eth_estimateExecutionGas', [tx, true])
const executionGas = await (env.ovmEth.provider as any).send(
'eth_estimateExecutionGas',
[tx, true]
)
const decoded = TxGasLimit.decode(gas)
expect(BigNumber.from(executionGas)).deep.eq(decoded)
})
Expand Down
182 changes: 85 additions & 97 deletions integration-tests/test/native-eth-ovm-calls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ describe('Native ETH value integration tests', () => {
'geth RPC does not match OVM_ETH.balanceOf'
)
// query address(this).balance solidity via eth_call as final check
const ovmAddressThisBalance0 = await ValueCalls0.callStatic.getAddressThisBalance()
const ovmAddressThisBalance01 = await ValueCalls1.callStatic.getAddressThisBalance()
const ovmAddressThisBalance0 =
await ValueCalls0.callStatic.getAddressThisBalance()
const ovmAddressThisBalance01 =
await ValueCalls1.callStatic.getAddressThisBalance()
expect(ovmAddressThisBalance0).to.deep.eq(
BigNumber.from(expectedBalances[0]),
'geth RPC does not match address(this).balance'
Expand Down Expand Up @@ -251,23 +253,19 @@ describe('Native ETH value integration tests', () => {

const sendAmount = 10

const [
outerSuccess,
outerReturndata,
] = await ValueCalls0.callStatic.sendWithData(
ValueCalls1.address,
sendAmount,
ValueCalls1.interface.encodeFunctionData('delegateCallToCallValue', [
ValueContext.address,
])
)
const [
innerSuccess,
innerReturndata,
] = ValueCalls1.interface.decodeFunctionResult(
'delegateCallToCallValue',
outerReturndata
)
const [outerSuccess, outerReturndata] =
await ValueCalls0.callStatic.sendWithData(
ValueCalls1.address,
sendAmount,
ValueCalls1.interface.encodeFunctionData('delegateCallToCallValue', [
ValueContext.address,
])
)
const [innerSuccess, innerReturndata] =
ValueCalls1.interface.decodeFunctionResult(
'delegateCallToCallValue',
outerReturndata
)
const delegatedOvmCALLVALUE = ValueContext.interface.decodeFunctionResult(
'getCallValue',
innerReturndata
Expand All @@ -286,48 +284,41 @@ describe('Native ETH value integration tests', () => {
const ValueContext = await Factory__ValueContext.deploy()
await ValueContext.deployTransaction.wait()

const [
delegatedSuccess,
delegatedReturndata,
] = await ValueCalls0.callStatic.delegateCallToAddressThisBalance(
ValueContext.address
)
const [delegatedSuccess, delegatedReturndata] =
await ValueCalls0.callStatic.delegateCallToAddressThisBalance(
ValueContext.address
)

expect(delegatedSuccess).to.be.true
expect(delegatedReturndata).to.deep.eq(BigNumber.from(initialBalance0))
})

it('should have correct address(this).balance through ovmDELEGATECALLs to same account', async () => {
const [
delegatedSuccess,
delegatedReturndata,
] = await ValueCalls0.callStatic.delegateCallToAddressThisBalance(
ValueCalls0.address
)
const [delegatedSuccess, delegatedReturndata] =
await ValueCalls0.callStatic.delegateCallToAddressThisBalance(
ValueCalls0.address
)

expect(delegatedSuccess).to.be.true
expect(delegatedReturndata).to.deep.eq(BigNumber.from(initialBalance0))
})

it('should allow delegate calls which preserve msg.value even with no balance going into the inner call', async () => {
const Factory__SendETHAwayAndDelegateCall: ContractFactory = await ethers.getContractFactory(
'SendETHAwayAndDelegateCall',
wallet
)
const SendETHAwayAndDelegateCall: Contract = await Factory__SendETHAwayAndDelegateCall.deploy()
const Factory__SendETHAwayAndDelegateCall: ContractFactory =
await ethers.getContractFactory('SendETHAwayAndDelegateCall', wallet)
const SendETHAwayAndDelegateCall: Contract =
await Factory__SendETHAwayAndDelegateCall.deploy()
await SendETHAwayAndDelegateCall.deployTransaction.wait()

const value = 17
const [
delegatedSuccess,
delegatedReturndata,
] = await SendETHAwayAndDelegateCall.callStatic.emptySelfAndDelegateCall(
ValueCalls0.address,
ValueCalls0.interface.encodeFunctionData('getCallValue'),
{
value,
}
)
const [delegatedSuccess, delegatedReturndata] =
await SendETHAwayAndDelegateCall.callStatic.emptySelfAndDelegateCall(
ValueCalls0.address,
ValueCalls0.interface.encodeFunctionData('getCallValue'),
{
value,
}
)

expect(delegatedSuccess).to.be.true
expect(delegatedReturndata).to.deep.eq(BigNumber.from(value))
Expand All @@ -343,8 +334,10 @@ describe('Native ETH value integration tests', () => {
getContractInterface('OVM_ExecutionManager', false),
env.l1Wallet.provider
)
const CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM = await OVM_ExecutionManager.CALL_WITH_VALUE_INTRINSIC_GAS()
CALL_WITH_VALUE_INTRINSIC_GAS = CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM.toNumber()
const CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM =
await OVM_ExecutionManager.CALL_WITH_VALUE_INTRINSIC_GAS()
CALL_WITH_VALUE_INTRINSIC_GAS =
CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM.toNumber()

const Factory__ValueGasMeasurer = await ethers.getContractFactory(
'ValueGasMeasurer',
Expand All @@ -357,14 +350,15 @@ describe('Native ETH value integration tests', () => {
it('a call with value to an empty account consumes <= the intrinsic gas including a buffer', async () => {
const value = 1
const gasLimit = 1_000_000
const minimalSendGas = await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall(
ethers.constants.AddressZero,
value,
gasLimit,
{
gasLimit: 2_000_000,
}
)
const minimalSendGas =
await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall(
ethers.constants.AddressZero,
value,
gasLimit,
{
gasLimit: 2_000_000,
}
)

const buffer = 1.2
expect(minimalSendGas * buffer).to.be.lte(CALL_WITH_VALUE_INTRINSIC_GAS)
Expand All @@ -384,67 +378,61 @@ describe('Native ETH value integration tests', () => {
const value = 1
const gasLimit = 1_000_000
// A revert, causing the ETH to be sent back, should consume the minimal possible gas for a nonzero ETH send
const minimalSendGas = await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall(
AutoRevert.address,
value,
gasLimit,
{
gasLimit: 2_000_000,
}
)
const minimalSendGas =
await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall(
AutoRevert.address,
value,
gasLimit,
{
gasLimit: 2_000_000,
}
)

const buffer = 1.2
expect(minimalSendGas * buffer).to.be.lte(CALL_WITH_VALUE_INTRINSIC_GAS)
})

it('a value call passing less than the intrinsic gas should appear to revert', async () => {
const Factory__PayableConstant: ContractFactory = await ethers.getContractFactory(
'PayableConstant',
wallet
)
const PayableConstant: Contract = await Factory__PayableConstant.deploy()
const Factory__PayableConstant: ContractFactory =
await ethers.getContractFactory('PayableConstant', wallet)
const PayableConstant: Contract =
await Factory__PayableConstant.deploy()
await PayableConstant.deployTransaction.wait()

const sendAmount = 15
const [
success,
returndata,
] = await ValueCalls0.callStatic.sendWithDataAndGas(
PayableConstant.address,
sendAmount,
PayableConstant.interface.encodeFunctionData('returnValue'),
CALL_WITH_VALUE_INTRINSIC_GAS - 1,
{
gasLimit: 2_000_000,
}
)
const [success, returndata] =
await ValueCalls0.callStatic.sendWithDataAndGas(
PayableConstant.address,
sendAmount,
PayableConstant.interface.encodeFunctionData('returnValue'),
CALL_WITH_VALUE_INTRINSIC_GAS - 1,
{
gasLimit: 2_000_000,
}
)

expect(success).to.eq(false)
expect(returndata).to.eq('0x')
})

it('a value call which runs out of gas does not out-of-gas the parent', async () => {
const Factory__TestOOG: ContractFactory = await ethers.getContractFactory(
'TestOOG',
wallet
)
const Factory__TestOOG: ContractFactory =
await ethers.getContractFactory('TestOOG', wallet)
const TestOOG: Contract = await Factory__TestOOG.deploy()
await TestOOG.deployTransaction.wait()

const sendAmount = 15
// Implicitly test that this call is not rejected
const [
success,
returndata,
] = await ValueCalls0.callStatic.sendWithDataAndGas(
TestOOG.address,
sendAmount,
TestOOG.interface.encodeFunctionData('runOutOfGas'),
CALL_WITH_VALUE_INTRINSIC_GAS * 2,
{
gasLimit: 2_000_000,
}
)
const [success, returndata] =
await ValueCalls0.callStatic.sendWithDataAndGas(
TestOOG.address,
sendAmount,
TestOOG.interface.encodeFunctionData('runOutOfGas'),
CALL_WITH_VALUE_INTRINSIC_GAS * 2,
{
gasLimit: 2_000_000,
}
)

expect(success).to.eq(false)
expect(returndata).to.eq('0x')
Expand Down
8 changes: 2 additions & 6 deletions integration-tests/test/native-eth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,8 @@ describe('Native ETH Integration Tests', async () => {
expect(receipt.events.length).to.equal(4)

// The first transfer event is fee payment
const [
,
firstTransferEvent,
secondTransferEvent,
depositEvent,
] = receipt.events
const [, firstTransferEvent, secondTransferEvent, depositEvent] =
receipt.events

expect(firstTransferEvent.event).to.equal('Transfer')
expect(firstTransferEvent.args.from).to.equal(env.l2Wallet.address)
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/test/ovmcontext.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ describe('OVM Context: Layer 2 EVM Context', () => {
'OVM_CanonicalTransactionChain'
)

CanonicalTransactionChain = CanonicalTransactionChainFactory.connect(
l1Wallet
).attach(ctcAddress)
CanonicalTransactionChain =
CanonicalTransactionChainFactory.connect(l1Wallet).attach(ctcAddress)

const OVMMulticallFactory = await ethers.getContractFactory(
'OVMMulticall',
Expand Down
6 changes: 2 additions & 4 deletions integration-tests/test/rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ describe('Basic RPC tests', () => {

it('should allow eth_calls with nonzero value', async () => {
// Deploy a contract to check msg.value of the call
const Factory__ValueContext: ContractFactory = await ethers.getContractFactory(
'ValueContext',
wallet
)
const Factory__ValueContext: ContractFactory =
await ethers.getContractFactory('ValueContext', wallet)
const ValueContext: Contract = await Factory__ValueContext.deploy()
await ValueContext.deployTransaction.wait()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ describe('BatchSubmitter', () => {
let OVM_StateCommitmentChain: Contract
let l2Provider: MockchainProvider
beforeEach(async () => {
const unwrapped_OVM_CanonicalTransactionChain = await Factory__OVM_CanonicalTransactionChain.deploy(
AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS
)
const unwrapped_OVM_CanonicalTransactionChain =
await Factory__OVM_CanonicalTransactionChain.deploy(
AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS
)
await unwrapped_OVM_CanonicalTransactionChain.init()

await AddressManager.setAddress(
Expand All @@ -169,11 +170,12 @@ describe('BatchSubmitter', () => {
sequencer
)

const unwrapped_OVM_StateCommitmentChain = await Factory__OVM_StateCommitmentChain.deploy(
AddressManager.address,
0, // fraudProofWindowSeconds
0 // sequencerPublishWindowSeconds
)
const unwrapped_OVM_StateCommitmentChain =
await Factory__OVM_StateCommitmentChain.deploy(
AddressManager.address,
0, // fraudProofWindowSeconds
0 // sequencerPublishWindowSeconds
)

await unwrapped_OVM_StateCommitmentChain.init()

Expand Down
Loading

0 comments on commit 305fff2

Please sign in to comment.