Skip to content

Commit

Permalink
update packages and config (paritytech#271)
Browse files Browse the repository at this point in the history
* update packages and config

* update web3

* fix tests and update api

* add launch seq
  • Loading branch information
joelamouche authored Mar 10, 2021
1 parent b8cca68 commit 302187d
Show file tree
Hide file tree
Showing 15 changed files with 5,762 additions and 13,080 deletions.
434 changes: 244 additions & 190 deletions tests/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"@polkadot/api": "^3.9.3",
"@polkadot/types": "^3.9.3",
"@polkadot/api": "^4.0.2",
"@polkadot/types": "^4.0.2",
"@types/chai": "^4.2.11",
"@types/mocha": "^8.0.0",
"chai": "^4.2.0",
Expand All @@ -21,6 +21,6 @@
"rimraf": "^3.0.2",
"ts-node": "9.1",
"typescript": "^3.9.6",
"web3": "^1.3.3"
"web3": "^1.3.4"
}
}
15 changes: 8 additions & 7 deletions tests/tests/test-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { Keyring } from "@polkadot/keyring";
import { step } from "mocha-steps";

import { createAndFinalizeBlock, describeWithMoonbeam, customRequest } from "./util";
import { GENESIS_ACCOUNT_BALANCE } from "./constants";
import {
GENESIS_ACCOUNT,
GENESIS_ACCOUNT_BALANCE,
GENESIS_ACCOUNT_PRIVATE_KEY,
TEST_ACCOUNT,
} from "./constants";
import { Event } from "@polkadot/types/interfaces";

describeWithMoonbeam("Moonbeam RPC (Balance)", `simple-specs.json`, (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY =
"0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";
const TEST_ACCOUNT = "0x1111111111111111111111111111111111111111";

step("genesis balance is setup correctly (web3)", async function () {
expect(await context.web3.eth.getBalance(GENESIS_ACCOUNT)).to.equal(
GENESIS_ACCOUNT_BALANCE.toString()
Expand Down Expand Up @@ -107,11 +107,12 @@ describeWithMoonbeam("Moonbeam RPC (Balance)", `simple-specs.json`, (context) =>
});

const TEST_ACCOUNT_2 = "0x1111111111111111111111111111111111111112";

step("transfer from polkadotjs should appear in ethereum", async function () {
this.timeout(15000);

const keyring = new Keyring({ type: "ethereum" });
const testAccount = await keyring.addFromUri(GENESIS_ACCOUNT_PRIVATE_KEY, null, "ethereum");
const testAccount = await keyring.createFromUri(GENESIS_ACCOUNT_PRIVATE_KEY);
await context.polkadotApi.tx.balances.transfer(TEST_ACCOUNT_2, 123).signAndSend(testAccount);

await createAndFinalizeBlock(context.polkadotApi);
Expand Down
6 changes: 1 addition & 5 deletions tests/tests/test-existential-deposit.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { expect } from "chai";
import { step } from "mocha-steps";
import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY, TEST_ACCOUNT } from "./constants";

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

describeWithMoonbeam("Moonbeam RPC (Existential Deposit)", `simple-specs.json`, (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY =
"0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";
const TEST_ACCOUNT = "0x1111111111111111111111111111111111111111";

step("Account is not reaped on zero balance", async function () {
const balance = await context.web3.eth.getBalance(GENESIS_ACCOUNT);
const tx = await context.web3.eth.accounts.signTransaction(
Expand Down
31 changes: 8 additions & 23 deletions tests/tests/test-gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,21 @@ import { expect } from "chai";

import { describeWithMoonbeam, customRequest, createAndFinalizeBlock } from "./util";
import { AbiItem } from "web3-utils";

describeWithMoonbeam("Moonbeam RPC (Gas)", `simple-specs.json`, (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY =
"0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";

import {
FIRST_CONTRACT_ADDRESS,
GENESIS_ACCOUNT,
GENESIS_ACCOUNT_PRIVATE_KEY,
// Solidity:
// contract test {
// function multiply(uint a) public pure returns(uint d) {return a * 7;}
// }
const TEST_CONTRACT_BYTECODE =
"0x6080604052348015600f57600080fd5b5060ae8061001e6000396000f3fe6080604052348015600f57600080fd" +
"5b506004361060285760003560e01c8063c6888fa114602d575b600080fd5b605660048036036020811015604157" +
"600080fd5b8101908080359060200190929190505050606c565b6040518082815260200191505060405180910390" +
"f35b600060078202905091905056fea265627a7a72315820f06085b229f27f9ad48b2ff3dd9714350c1698a37853" +
"a30136fa6c5a7762af7364736f6c63430005110032";

const TEST_CONTRACT_ABI = {
constant: true,
inputs: [{ internalType: "uint256", name: "a", type: "uint256" }],
name: "multiply",
outputs: [{ internalType: "uint256", name: "d", type: "uint256" }],
payable: false,
stateMutability: "pure",
type: "function",
} as AbiItem;
TEST_CONTRACT_BYTECODE,
TEST_CONTRACT_ABI,
} from "./constants";

describeWithMoonbeam("Moonbeam RPC (Gas)", `simple-specs.json`, (context) => {
// Those test are ordered. In general this should be avoided, but due to the time it takes
// to spin up a Moonbeam node, it saves a lot of time.
const FIRST_CONTRACT_ADDRESS = "0xc2bf5f29a4384b1ab0c063e1c666f02121b6084a";

it("eth_estimateGas for contract creation", async function () {
expect(
Expand Down
6 changes: 1 addition & 5 deletions tests/tests/test-nonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import { step } from "mocha-steps";

import { createAndFinalizeBlock, describeWithMoonbeam, customRequest } from "./util";
import { Keyring } from "@polkadot/keyring";
import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY, TEST_ACCOUNT } from "./constants";

describeWithMoonbeam("Moonbeam RPC (Nonce)", `simple-specs.json`, (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY =
"0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";
const TEST_ACCOUNT = "0x1111111111111111111111111111111111111111";

step("get nonce", async function () {
this.timeout(10_000);
const tx = await context.web3.eth.accounts.signTransaction(
Expand Down
12 changes: 1 addition & 11 deletions tests/tests/test-pending-pool.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import { expect } from "chai";
import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY, TEST_CONTRACT_BYTECODE } from "./constants";

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

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

// Solidity: contract test { function multiply(uint a) public pure returns(uint d)
// {return a * 7;}}
const TEST_CONTRACT_BYTECODE =
"0x6080604052348015600f57600080fd5b5060ae8061001e6000396000f3fe6080604052348015600f57600080fd" +
"5b506004361060285760003560e01c8063c6888fa114602d575b600080fd5b605660048036036020811015604157" +
"600080fd5b8101908080359060200190929190505050606c565b6040518082815260200191505060405180910390" +
"f35b600060078202905091905056fea265627a7a72315820f06085b229f27f9ad48b2ff3dd9714350c1698a37853" +
"a30136fa6c5a7762af7364736f6c63430005110032";
const FIRST_CONTRACT_ADDRESS = "0xc2bf5f29a4384b1ab0c063e1c666f02121b6084a";

it("should return a pending transaction", async function () {
this.timeout(15000);
Expand Down
5 changes: 1 addition & 4 deletions tests/tests/test-polkadot-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import { step } from "mocha-steps";

import { createAndFinalizeBlock, describeWithMoonbeam } from "./util";
import { AnyTuple, IEvent } from "@polkadot/types/types";
import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY } from "./constants";

describeWithMoonbeam("Moonbeam Polkadot API", `simple-specs.json`, (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_ACCOUNT_PRIVATE_KEY =
"0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342";

step("api can retrieve last header", async function () {
const lastHeader = await context.polkadotApi.rpc.chain.getHeader();
expect(Number(lastHeader.number) >= 0).to.be.true;
Expand Down
2 changes: 0 additions & 2 deletions tests/tests/test-stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { step } from "mocha-steps";
import { describeWithMoonbeam } from "./util";
import { GLMR } from "./constants";

import BigNumber from "bignumber.js";

describeWithMoonbeam("Moonbeam RPC (Stake)", `simple-specs.json`, (context) => {
const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b";
const GENESIS_STAKED = 1_000n * GLMR;
Expand Down
69 changes: 5 additions & 64 deletions tools/config_moonbeam.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"parachains": [
{
"bin": "../target/release/moonbase-alphanet",
"bin": "../target/release/moonbeam",
"id": "200",
"rpcPort": 36846,
"wsPort": 36946,
Expand All @@ -38,7 +38,7 @@
]
},
{
"bin": "../target/release/moonbase-alphanet",
"bin": "../target/release/moonbeam",
"id": "200",
"rpcPort": 36847,
"wsPort": 36947,
Expand All @@ -55,68 +55,9 @@
}
],
"simpleParachains": [],
"hrmpChannels": [],
"types": {
"HrmpChannelId": {
"sender": "u32",
"receiver": "u32"
},
"SignedAvailabilityBitfield": {
"payload": "BitVec",
"validator_index": "u32",
"signature": "Signature"
},
"SignedAvailabilityBitfields": "Vec<SignedAvailabilityBitfield>",
"ValidatorSignature": "Signature",
"HeadData": "Vec<u8>",
"CandidateDescriptor": {
"para_id": "u32",
"relay_parent": "Hash",
"collator_id": "Hash",
"persisted_validation_data_hash": "Hash",
"pov_hash": "Hash",
"erasure_root": "Hash",
"signature": "Signature"
},
"CandidateReceipt": {
"descriptor": "CandidateDescriptor",
"commitments_hash": "Hash"
},
"UpwardMessage": "Vec<u8>",
"OutboundHrmpMessage": {
"recipient": "u32",
"data": "Vec<u8>"
},
"ValidationCode": "Vec<u8>",
"CandidateCommitments": {
"upward_messages": "Vec<UpwardMessage>",
"horizontal_messages": "Vec<OutboundHrmpMessage>",
"new_validation_code": "Option<ValidationCode>",
"head_data": "HeadData",
"processed_downward_messages": "u32",
"hrmp_watermark": "BlockNumber"
},
"CommittedCandidateReceipt": {
"descriptor": "CandidateDescriptor",
"commitments": "CandidateCommitments"
},
"ValidityAttestation": {
"_enum": {
"DummyOffsetBy1": "Raw",
"Implicit": "ValidatorSignature",
"Explicit": "ValidatorSignature"
}
},
"BackedCandidate": {
"candidate": "CommittedCandidateReceipt",
"validity_votes": "Vec<ValidityAttestation>",
"validator_indices": "BitVec"
},
"CandidatePendingAvailablility": {
"core": "u32",
"descriptor": "CandidateDescriptor",
"availability_votes": "BitVec",
"relay_parent_number": "BlockNumber",
"backed_in_number": "BlockNumber"
}
"Address": "MultiAddress",
"LookupSource": "MultiAddress"
}
}
4 changes: 2 additions & 2 deletions tools/moonbeam-launch.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import main from "polkadot-launch";
main();
import { start } from "polkadot-launch";
start("config_moonbeam.json");
2 changes: 2 additions & 0 deletions tools/moonbeam-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import main from "polkadot-launch";
main();
Loading

0 comments on commit 302187d

Please sign in to comment.