MyCrypto/spec/integration/data.int.ts
Daniel Ternyak ab5fa1a799
Support Non-Ethereum Networks (#849)
* Make UnlockHeader a PureComponent

* MVP

* actually disable wallet format if not determined to be valid format for wallet

* default to correct derivation in mnemonic modal

* cleanup

* fix tslint

* use enums for HD wallet getPath

* Add stricter typing

* Fix labels not updating on selector

* Ban hardware wallet support for custom network unsupported chainIds

* Fix type error

* Fix custom node dPath not being saved

* Fix mnemonic modal

* default path bugfixes

* add react-select

* misc fixes; rabbit holing hard.

* fix tslint

* revert identicon changes

* reload on network change :/

* actually reload on network change

* really really reload on network change

* tslint fixes

* Update styles

* set table width

* fix package versioning

* push broken sagas

* Fix saga test

* fix tslint

* address round of review

* move non-selectors out to utilty; adjust reload timer

* cleanup network util comments

* manage wallet disable at WalletDecrypt instead of in both WalletDecrypt and WalletButton

* Separate WalletDecrypt props into ownProps / StateProps

* disable payment requests on non-eth networks

* specialize connect; separate props

* remove unused state prop

* remove bad import

* create tests for networks

* Clarify Lite-Send error on non-ethereum networkS

* remove string option for network config name

* Create concept of always-on 'EXTRA_PATHS'; include SINGULAR_DTV legacy dPath in 'EXTRA_PATHS'

* fix multiple imports

* address PR comments
2018-01-20 14:06:28 -06:00

83 lines
2.3 KiB
TypeScript

import { NODES, NodeConfig } from 'config';
import { RPCNode } from '../../common/libs/nodes';
import { Validator } from 'jsonschema';
import { schema } from '../../common/libs/validators';
import 'url-search-params-polyfill';
import EtherscanNode from 'libs/nodes/etherscan';
import InfuraNode from 'libs/nodes/infura';
import RpcNodeTestConfig from './RpcNodeTestConfig';
const v = new Validator();
const validRequests = {
address: '0x72948fa4200d10ffaa7c594c24bbba6ef627d4a3',
transaction: {
data: '',
from: '0x72948fa4200d10ffaa7c594c24bbba6ef627d4a3',
to: '0x72948fa4200d10ffaa7c594c24bbba6ef627d4a3',
value: '0xde0b6b3a7640000'
},
token: {
address: '0x4156d3342d5c385a87d264f90653733592000581',
symbol: 'SALT',
decimal: 8
}
};
const testGetBalance = (n: RPCNode) => {
return n.client
.call(n.requests.getBalance(validRequests.address))
.then(data => v.validate(data, schema.RpcNode));
};
const testEstimateGas = (n: RPCNode) => {
return n.client
.call(n.requests.estimateGas(validRequests.transaction))
.then(data => v.validate(data, schema.RpcNode));
};
const testGetTokenBalance = (n: RPCNode) => {
const { address, token } = validRequests;
return n.client
.call(n.requests.getTokenBalance(address, token))
.then(data => v.validate(data, schema.RpcNode));
};
const RPCTests = {
getBalance: testGetBalance,
estimateGas: testEstimateGas,
getTokenBalance: testGetTokenBalance
};
function testRpcRequests(node: RPCNode, service: string) {
Object.keys(RPCTests).forEach(testType => {
describe(`RPC (${service}) should work`, () => {
it(
`RPC: ${testType} ${service}`,
() => {
return RPCTests[testType](node).then(d => expect(d.valid).toBeTruthy());
},
10000
);
});
});
}
const mapNodeEndpoints = (nodes: { [key: string]: NodeConfig }) => {
const { RpcNodes, EtherscanNodes, InfuraNodes } = RpcNodeTestConfig;
RpcNodes.forEach(n => {
testRpcRequests(nodes[n].lib as RPCNode, `${nodes[n].service} ${nodes[n].network}`);
});
EtherscanNodes.forEach(n => {
testRpcRequests(nodes[n].lib as EtherscanNode, `${nodes[n].service} ${nodes[n].network}`);
});
InfuraNodes.forEach(n => {
testRpcRequests(nodes[n].lib as InfuraNode, `${nodes[n].service} ${nodes[n].network}`);
});
};
mapNodeEndpoints(NODES);