From fc91d0c03851d51f950d94106cec3f30b6de08ec Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Thu, 21 Sep 2023 20:57:35 -0700 Subject: [PATCH] [e2e] Add eth_gasPrice json rpc method test. --- test/e2e/json-rpc/eth_gasPrice.spec.js | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/e2e/json-rpc/eth_gasPrice.spec.js diff --git a/test/e2e/json-rpc/eth_gasPrice.spec.js b/test/e2e/json-rpc/eth_gasPrice.spec.js new file mode 100644 index 000000000000..28053cef442d --- /dev/null +++ b/test/e2e/json-rpc/eth_gasPrice.spec.js @@ -0,0 +1,37 @@ +const { strict: assert } = require('assert'); +const { withFixtures, defaultGanacheOptions } = require('../helpers'); +const FixtureBuilder = require('../fixture-builder'); + +describe('eth_gasPrice', function () { + it('executes gas price json rpc call', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withPermissionControllerConnectedToTestDapp() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.title, + }, + async ({ driver }) => { + await driver.navigate(); + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); + + // eth_gasPrice + await driver.openNewPage(`http://127.0.0.1:8080`); + + const gasPriceRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'eth_gasPrice', + }); + + const gasPrice = await driver.executeScript( + `return window.ethereum.request(${gasPriceRequest})`, + ); + + assert.strictEqual(gasPrice, '0x77359400'); // 2000000000 + }, + ); + }); +});