Commit daa26208 authored by Liam Horne's avatar Liam Horne Committed by GitHub

test: add rpc test for eth_getBalance (#521)

parent 0497d7df
...@@ -3,9 +3,12 @@ import { Wallet, BigNumber } from 'ethers' ...@@ -3,9 +3,12 @@ import { Wallet, BigNumber } from 'ethers'
import chai, { expect } from 'chai' import chai, { expect } from 'chai'
import { sleep, l2Provider, GWEI } from './shared/utils' import { sleep, l2Provider, GWEI } from './shared/utils'
import chaiAsPromised from 'chai-as-promised' import chaiAsPromised from 'chai-as-promised'
import { OptimismEnv } from './shared/env'
chai.use(chaiAsPromised) chai.use(chaiAsPromised)
describe('Basic RPC tests', () => { describe('Basic RPC tests', () => {
let env: OptimismEnv;
const DEFAULT_TRANSACTION = { const DEFAULT_TRANSACTION = {
to: '0x' + '1234'.repeat(10), to: '0x' + '1234'.repeat(10),
gasLimit: 4000000, gasLimit: 4000000,
...@@ -17,6 +20,10 @@ describe('Basic RPC tests', () => { ...@@ -17,6 +20,10 @@ describe('Basic RPC tests', () => {
const provider = injectL2Context(l2Provider) const provider = injectL2Context(l2Provider)
const wallet = Wallet.createRandom().connect(provider) const wallet = Wallet.createRandom().connect(provider)
before(async () => {
env = await OptimismEnv.new()
})
describe('eth_sendRawTransaction', () => { describe('eth_sendRawTransaction', () => {
it('should correctly process a valid transaction', async () => { it('should correctly process a valid transaction', async () => {
const tx = DEFAULT_TRANSACTION const tx = DEFAULT_TRANSACTION
...@@ -119,6 +126,14 @@ describe('Basic RPC tests', () => { ...@@ -119,6 +126,14 @@ describe('Basic RPC tests', () => {
}) })
}) })
describe('eth_getBalance', () => {
it('should get the OVM_ETH balance', async () => {
const rpcBalance = await provider.getBalance(env.l2Wallet.address)
const contractBalance = await env.ovmEth.balanceOf(env.l2Wallet.address)
expect(rpcBalance).to.be.deep.eq(contractBalance)
})
})
describe('eth_chainId', () => { describe('eth_chainId', () => {
it('should get the correct chainid', async () => { it('should get the correct chainid', async () => {
const { chainId } = await provider.getNetwork() const { chainId } = await provider.getNetwork()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment