Skip to content

Commit

Permalink
ts-tests: switch to use builtin dev config directly (paritytech#353)
Browse files Browse the repository at this point in the history
* ts-tests: switch to use builtin dev config directly

* Add evm balance for dev config
  • Loading branch information
sorpaas authored Apr 9, 2021
1 parent 72f54fe commit 15759a8
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 75 deletions.
20 changes: 17 additions & 3 deletions template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use sp_core::{Pair, Public, sr25519};
use std::{str::FromStr, collections::BTreeMap};
use sp_core::{H160, U256, Pair, Public, sr25519};
use frontier_template_runtime::{
AccountId, AuraConfig, BalancesConfig, EVMConfig, EthereumConfig, GenesisConfig, GrandpaConfig,
SudoConfig, SystemConfig, WASM_BINARY, Signature
Expand All @@ -7,7 +8,6 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_finality_grandpa::AuthorityId as GrandpaId;
use sp_runtime::traits::{Verify, IdentifyAccount};
use sc_service::ChainType;
use std::collections::BTreeMap;

// The URL for the telemetry server.
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
Expand Down Expand Up @@ -155,7 +155,21 @@ fn testnet_genesis(
key: root_key,
},
pallet_evm: EVMConfig {
accounts: BTreeMap::new(),
accounts: {
let mut map = BTreeMap::new();
map.insert(
H160::from_str("6be02d1d3665660d22ff9624b7be0551ee1ac91b")
.expect("internal H160 is valid; qed"),
pallet_evm::GenesisAccount {
balance: U256::from_str("0xffffffffffffffffffffffffffffffff")
.expect("internal U256 is valid; qed"),
code: Default::default(),
nonce: Default::default(),
storage: Default::default(),
}
);
map
},
},
pallet_ethereum: EthereumConfig {},
}
Expand Down
46 changes: 0 additions & 46 deletions ts-tests/frontier-test-specs/simple-specs.json

This file was deleted.

2 changes: 1 addition & 1 deletion ts-tests/tests/test-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { step } from "mocha-steps";

import { createAndFinalizeBlock, describeWithFrontier, customRequest } from "./util";

describeWithFrontier("Frontier RPC (Balance)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Balance)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_BALANCE = "340282366920938463463374607431768211455";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { step } from "mocha-steps";

import { createAndFinalizeBlock, describeWithFrontier } from "./util";

describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Block)", (context) => {
let previousBlock;
// Those tests are dependant of each other in the given order.
// The reason is to avoid having to restart the node each time
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-bloom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { step } from "mocha-steps";

import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";

describeWithFrontier("Frontier RPC (Bloom)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Bloom)", (context) => {

const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-contract-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Test from "../build/contracts/Test.json"
import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";
import { AbiItem } from "web3-utils";

describeWithFrontier("Frontier RPC (Contract Methods)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Contract Methods)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";

Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-contract-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Test from "../build/contracts/Storage.json"
import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";
import { AbiItem } from "web3-utils";

describeWithFrontier("Frontier RPC (Contract)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Contract)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";

Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from "chai";
import Test from "../build/contracts/Test.json"
import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";

describeWithFrontier("Frontier RPC (Contract)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Contract)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";

Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";

import { customRequest, describeWithFrontier } from "./util";

describeWithFrontier("Frontier RPC (Deprecated)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Deprecated)", (context) => {
// List of deprecated methods
[
{ method: "eth_getCompilers", params: [] },
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-filter-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { create } from "ts-node";

import { createAndFinalizeBlock, describeWithFrontier, customRequest } from "./util";

describeWithFrontier("Frontier RPC (EthFilterApi)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (EthFilterApi)", (context) => {

const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Test from "../build/contracts/Test.json"
import { describeWithFrontier, createAndFinalizeBlock } from "./util";
import { AbiItem } from "web3-utils";

describeWithFrontier("Frontier RPC (Gas)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Gas)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";

const TEST_CONTRACT_BYTECODE = Test.bytecode;
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-nonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { step } from "mocha-steps";

import { createAndFinalizeBlock, describeWithFrontier, customRequest } from "./util";

describeWithFrontier("Frontier RPC (Nonce)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Nonce)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";
const TEST_ACCOUNT = "0x1111111111111111111111111111111111111111";
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-pending-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";

import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";

describeWithFrontier("Frontier RPC (Pending Pool)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Pending Pool)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";

Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-precompiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ECRecoverTests from "../build/contracts/ECRecoverTests.json"
import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";
import { AbiItem } from "web3-utils";

describeWithFrontier("Frontier RPC (Precompile)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Precompile)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";

Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-revert-reason.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ExplicitRevertReason from "../build/contracts/ExplicitRevertReason.json"
import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";
import { AbiItem } from "web3-utils";

describeWithFrontier("Frontier RPC (Revert Reason)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Revert Reason)", (context) => {

let contractAddress;

Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-revert-receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";

import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";

describeWithFrontier("Frontier RPC (Constructor Revert)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Constructor Revert)", (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY =
"0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-rpc-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describeWithFrontier } from "./util";

// All test for the RPC

describeWithFrontier("Frontier RPC (Constant)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Constant)", (context) => {
it("should have 0 hashrate", async function () {
expect(await context.web3.eth.getHashrate()).to.equal(0);
});
Expand Down
3 changes: 1 addition & 2 deletions ts-tests/tests/test-state-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { step } from "mocha-steps";

import { createAndFinalizeBlock, describeWithFrontier } from "./util";

describeWithFrontier("Frontier RPC (State root hash)", `simple-specs.json`, (context) => {

describeWithFrontier("Frontier RPC (State root hash)", (context) => {
let block;
step("should calculate a valid intermediate state root hash", async function () {
await createAndFinalizeBlock(context.web3);
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { step } from "mocha-steps";

import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util";

describeWithFrontier("Frontier RPC (Subscription)", `simple-specs.json`, (context) => {
describeWithFrontier("Frontier RPC (Subscription)", (context) => {

let subscription;
let logs_generated = 0;
Expand Down
3 changes: 1 addition & 2 deletions ts-tests/tests/test-web3api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { step } from "mocha-steps";

import { describeWithFrontier, customRequest } from "./util";

describeWithFrontier("Frontier RPC (Web3Api)", `simple-specs.json`, (context) => {

describeWithFrontier("Frontier RPC (Web3Api)", (context) => {
step("should get client version", async function () {
const version = await context.web3.eth.getNodeInfo();
expect(version).to.be.equal("node-frontier-template/v1.1/fc-rpc-2.0.0-dev");
Expand Down
10 changes: 4 additions & 6 deletions ts-tests/tests/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { spawn, ChildProcess } from "child_process";
export const PORT = 19931;
export const RPC_PORT = 19932;
export const WS_PORT = 19933;
export const SPECS_PATH = `./frontier-test-specs`;

export const DISPLAY_LOG = process.env.FRONTIER_LOG || false;
export const FRONTIER_LOG = process.env.FRONTIER_LOG || "info";
Expand Down Expand Up @@ -45,16 +44,15 @@ export async function createAndFinalizeBlock(web3: Web3) {
}
}

export async function startFrontierNode(specFilename: string, provider?: string): Promise<{ web3: Web3; binary: ChildProcess }> {

export async function startFrontierNode(provider?: string): Promise<{ web3: Web3; binary: ChildProcess }> {
var web3;
if (!provider || provider == 'http') {
web3 = new Web3(`http://localhost:${RPC_PORT}`);
}

const cmd = BINARY_PATH;
const args = [
`--chain=${SPECS_PATH}/${specFilename}`,
`--chain=dev`,
`--validator`, // Required by manual sealing to author the blocks
`--execution=Native`, // Faster execution using native
`--no-telemetry`,
Expand Down Expand Up @@ -122,14 +120,14 @@ export async function startFrontierNode(specFilename: string, provider?: string)
return { web3, binary };
}

export function describeWithFrontier(title: string, specFilename: string, cb: (context: { web3: Web3 }) => void, provider?: string) {
export function describeWithFrontier(title: string, cb: (context: { web3: Web3 }) => void, provider?: string) {
describe(title, () => {
let context: { web3: Web3 } = { web3: null };
let binary: ChildProcess;
// Making sure the Frontier node has started
before("Starting Frontier Test Node", async function () {
this.timeout(SPAWNING_TIME);
const init = await startFrontierNode(specFilename, provider);
const init = await startFrontierNode(provider);
context.web3 = init.web3;
binary = init.binary;
});
Expand Down

0 comments on commit 15759a8

Please sign in to comment.