Skip to content

Commit

Permalink
Merge branch 'main' into refactor/973-throw-rpc-error-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistevam authored Sep 25, 2023
2 parents 1c7e573 + b96f94b commit 96720f3
Show file tree
Hide file tree
Showing 13 changed files with 983 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ describe('TokenBalancesController', () => {
messenger.subscribe('NetworkController:stateChange', listener),
onTokenListStateChange: sinon.stub(),
getERC20TokenName: sinon.stub(),
getNetworkClientById: sinon.stub() as any,
messenger: undefined as unknown as TokensControllerMessenger,
});
const address = '0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0';
Expand Down Expand Up @@ -185,6 +186,7 @@ describe('TokenBalancesController', () => {
messenger.subscribe('NetworkController:stateChange', listener),
onTokenListStateChange: sinon.stub(),
getERC20TokenName: sinon.stub(),
getNetworkClientById: sinon.stub() as any,
messenger: undefined as unknown as TokensControllerMessenger,
});
const errorMsg = 'Failed to get balance';
Expand Down Expand Up @@ -241,6 +243,7 @@ describe('TokenBalancesController', () => {
messenger.subscribe('NetworkController:stateChange', listener),
onTokenListStateChange: sinon.stub(),
getERC20TokenName: sinon.stub(),
getNetworkClientById: sinon.stub() as any,
messenger: undefined as unknown as TokensControllerMessenger,
});

Expand All @@ -256,7 +259,11 @@ describe('TokenBalancesController', () => {
{ interval: 1337 },
);
const updateBalances = sinon.stub(tokenBalances, 'updateBalances');
await tokensController.addToken('0x00', 'FOO', 18);
await tokensController.addToken({
address: '0x00',
symbol: 'FOO',
decimals: 18,
});
const { tokens } = tokensController.state;
const found = tokens.filter((token: Token) => token.address === '0x00');
expect(found.length > 0).toBe(true);
Expand Down
37 changes: 19 additions & 18 deletions packages/assets-controllers/src/TokenDetectionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ describe('TokenDetectionController', () => {
preferences = new PreferencesController({}, { useTokenDetection: true });
controllerMessenger = getControllerMessenger();
sinon
.stub(TokensController.prototype, '_instantiateNewEthersProvider')
.callsFake(() => null);
.stub(TokensController.prototype, '_createEthersContract')
.callsFake(() => null as any);

tokensController = new TokensController({
chainId: ChainId.mainnet,
Expand All @@ -180,6 +180,7 @@ describe('TokenDetectionController', () => {
onNetworkStateChangeListeners.push(listener),
onTokenListStateChange: sinon.stub(),
getERC20TokenName: sinon.stub(),
getNetworkClientById: sinon.stub() as any,
messenger: undefined as unknown as TokensControllerMessenger,
});

Expand Down Expand Up @@ -336,18 +337,18 @@ describe('TokenDetectionController', () => {

await tokenDetection.start();

await tokensController.addToken(
sampleTokenA.address,
sampleTokenA.symbol,
sampleTokenA.decimals,
);
await tokensController.addToken({
address: sampleTokenA.address,
symbol: sampleTokenA.symbol,
decimals: sampleTokenA.decimals,
});

await tokensController.addToken(
sampleTokenB.address,
sampleTokenB.symbol,
sampleTokenB.decimals,
{ name: sampleTokenB.name },
);
await tokensController.addToken({
address: sampleTokenB.address,
symbol: sampleTokenB.symbol,
decimals: sampleTokenB.decimals,
name: sampleTokenB.name,
});

tokensController.ignoreTokens([sampleTokenA.address]);

Expand All @@ -368,11 +369,11 @@ describe('TokenDetectionController', () => {

await tokenDetection.start();

await tokensController.addToken(
sampleTokenA.address,
sampleTokenA.symbol,
sampleTokenA.decimals,
);
await tokensController.addToken({
address: sampleTokenA.address,
symbol: sampleTokenA.symbol,
decimals: sampleTokenA.decimals,
});

tokensController.ignoreTokens([sampleTokenA.address]);

Expand Down
Loading

0 comments on commit 96720f3

Please sign in to comment.