-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support Ethereum for dev node * Add first test * Add rpc constants test * Add balance test * Add contract test * Finish balance and contract basic tests * Add bloom filter test * Test `eth_getCode` * Test nonce update * Test opcodes * Add event test * Finally, basic tests are covered.
- Loading branch information
1 parent
3399b66
commit 1537527
Showing
19 changed files
with
10,008 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Web3 from "web3"; | ||
import { JsonRpcResponse } from "web3-core-helpers"; | ||
|
||
export const CHAIN_ID = 43; | ||
export const HOST_HTTP_URL = "http://127.0.0.1:9933"; | ||
export const HOST_WS_URL = "ws://127.0.0.1:9944"; | ||
// TODO: https://github.com/darwinia-network/darwinia-2.0/issues/248 | ||
export const BLOCK_GAS_LIMIT = 9375000; | ||
export const DEFAULT_GAS = 4000000; | ||
// EXTRINSIC_GAS_LIMIT = [BLOCK_GAS_LIMIT - BLOCK_GAS_LIMIT * (NORMAL_DISPATCH_RATIO - AVERAGE_ON_INITIALIZE_RATIO) - EXTRINSIC_BASE_Weight] / WEIGHT_PER_GAS = (1_000_000_000_000 * 2 * (0.75-0.025) - 125_000_000) / 40_000 | ||
export const EXTRINSIC_GAS_LIMIT = 9059375; | ||
|
||
// Accounts builtin | ||
export const FAITH = "0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d"; | ||
export const FAITH_P = "0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df"; | ||
|
||
export async function customRequest(web3: Web3, method: string, params: any[]) { | ||
return new Promise<JsonRpcResponse>((resolve, reject) => { | ||
(web3.currentProvider as any).send( | ||
{ | ||
jsonrpc: "2.0", | ||
id: 1, | ||
method, | ||
params, | ||
}, | ||
(error: Error | null, result?: JsonRpcResponse) => { | ||
if (error) { | ||
reject( | ||
`Failed to send custom request (${method} (${params.join(",")})): ${ | ||
error.message || error.toString() | ||
}` | ||
); | ||
} | ||
resolve(result); | ||
} | ||
); | ||
}); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity ^0.6.0; | ||
|
||
contract JSON_Test { | ||
event Log0(uint256 value); | ||
event Log0Anonym(uint256 value) anonymous; | ||
|
||
event Log1(bool indexed aBool, uint256 value); | ||
event Log1Anonym(bool indexed aBool, uint256 value) anonymous; | ||
|
||
event Log2(bool indexed aBool, address indexed aAddress, uint256 value); | ||
event Log2Anonym( | ||
bool indexed aBool, | ||
address indexed aAddress, | ||
uint256 value | ||
) anonymous; | ||
|
||
event Log3( | ||
bool indexed aBool, | ||
address indexed aAddress, | ||
bytes32 indexed aBytes32, | ||
uint256 value | ||
); | ||
event Log3Anonym( | ||
bool indexed aBool, | ||
address indexed aAddress, | ||
bytes32 indexed aBytes32, | ||
uint256 value | ||
) anonymous; | ||
|
||
constructor() public {} | ||
|
||
function fireEventLog0() public { | ||
emit Log0(42); | ||
} | ||
|
||
function fireEventLog0Anonym() public { | ||
emit Log0Anonym(42); | ||
} | ||
|
||
function fireEventLog1() public { | ||
emit Log1(true, 42); | ||
} | ||
|
||
function fireEventLog1Anonym() public { | ||
emit Log1Anonym(true, 42); | ||
} | ||
|
||
function fireEventLog2() public { | ||
emit Log2(true, msg.sender, 42); | ||
} | ||
|
||
function fireEventLog2Anonym() public { | ||
emit Log2Anonym(true, msg.sender, 42); | ||
} | ||
|
||
function fireEventLog3() public { | ||
emit Log3( | ||
true, | ||
msg.sender, | ||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, | ||
42 | ||
); | ||
} | ||
|
||
function fireEventLog3Anonym() public { | ||
emit Log3Anonym( | ||
true, | ||
msg.sender, | ||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, | ||
42 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity ^0.6.0; | ||
|
||
contract Incrementer { | ||
uint256 public number; | ||
|
||
constructor(uint256 _initialNumber) public { | ||
number = _initialNumber; | ||
} | ||
|
||
function increment(uint256 _value) public { | ||
number = number + _value; | ||
} | ||
|
||
function reset() public { | ||
number = 0; | ||
} | ||
} |
Oops, something went wrong.