Skip to content

Commit

Permalink
chore: getting basic test passing
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Aug 16, 2024
1 parent 78e5c03 commit dff1c05
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 50 deletions.
File renamed without changes.
17 changes: 0 additions & 17 deletions test/data/3de7f859450540bb5aa2948cf30b14815e73623e.json

This file was deleted.

33 changes: 33 additions & 0 deletions test/data/a041de03f2a7ee6c133465c8c6b2b286704a5d8f.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"request": {
"path": "https://jungle4.greymass.com/v1/chain/get_info",
"params": {
"method": "GET",
"headers": {}
}
},
"status": 200,
"json": {
"server_version": "17b89a28",
"chain_id": "73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d",
"head_block_num": 156088678,
"last_irreversible_block_num": 156088343,
"last_irreversible_block_id": "094db817b49cfc17bf85a65bc86c3fe70b2bb18030a0ca863c4b2abb09c0fb8c",
"head_block_id": "094db96623b26ac406bd612b3160e80cda4963332a39e4d23005deeb094e34e1",
"head_block_time": "2024-08-16T19:26:05.000",
"head_block_producer": "eosriobrazil",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 200000,
"block_net_limit": 1048576,
"server_version_string": "v1.0.0-beta2.1",
"fork_db_head_block_num": 156088678,
"fork_db_head_block_id": "094db96623b26ac406bd612b3160e80cda4963332a39e4d23005deeb094e34e1",
"server_full_version_string": "v1.0.0-beta2.1-17b89a28b525826db2986bc20106a6e8202b22a9",
"total_cpu_weight": "120573498838233",
"total_net_weight": "117542107821577",
"earliest_available_block_num": 155899613,
"last_irreversible_block_time": "2024-08-16T19:23:17.500"
},
"text": "{\"server_version\":\"17b89a28\",\"chain_id\":\"73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d\",\"head_block_num\":156088678,\"last_irreversible_block_num\":156088343,\"last_irreversible_block_id\":\"094db817b49cfc17bf85a65bc86c3fe70b2bb18030a0ca863c4b2abb09c0fb8c\",\"head_block_id\":\"094db96623b26ac406bd612b3160e80cda4963332a39e4d23005deeb094e34e1\",\"head_block_time\":\"2024-08-16T19:26:05.000\",\"head_block_producer\":\"eosriobrazil\",\"virtual_block_cpu_limit\":200000000,\"virtual_block_net_limit\":1048576000,\"block_cpu_limit\":200000,\"block_net_limit\":1048576,\"server_version_string\":\"v1.0.0-beta2.1\",\"fork_db_head_block_num\":156088678,\"fork_db_head_block_id\":\"094db96623b26ac406bd612b3160e80cda4963332a39e4d23005deeb094e34e1\",\"server_full_version_string\":\"v1.0.0-beta2.1-17b89a28b525826db2986bc20106a6e8202b22a9\",\"total_cpu_weight\":\"120573498838233\",\"total_net_weight\":\"117542107821577\",\"earliest_available_block_num\":155899613,\"last_irreversible_block_time\":\"2024-08-16T19:23:17.500\"}"
}
32 changes: 0 additions & 32 deletions test/data/a91ac04b00106a44611383931aef281f37cd304e.json

This file was deleted.

18 changes: 18 additions & 0 deletions test/data/ed314e8a151304a30043198b7b9e9df34a14aaeb.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/tests/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import {
} from '@wharfkit/mock-data'

import {WalletPluginMetaMask} from '$lib'
import {setupEthereumMock} from './mocks/ethereum'

suite('wallet plugin', function () {
setup(function () {
setupEthereumMock()
})

test('login and sign', async function () {
const kit = new SessionKit(
{

Check failure on line 20 in test/tests/common.ts

View workflow job for this annotation

GitHub Actions / Node.js v18

Argument of type '{ walletPlugins: WalletPluginMetaMask[]; appName: NameType; chains: ChainDefinitionType[]; ui: UserInterface; }' is not assignable to parameter of type 'SessionKitArgs'.
Expand Down
42 changes: 42 additions & 0 deletions test/tests/mocks/ethereum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/// <reference path="../../../global.d.ts" />

import {MetaMaskInpageProvider} from '@metamask/providers'

class MockMetaMaskInpageProvider implements Partial<MetaMaskInpageProvider> {
request(args: {method: string; params?: any}) {
switch (args.method) {
case 'wallet_getSnaps':
return Promise.resolve({})
case 'wallet_requestSnaps':
return Promise.resolve({
'local:http://localhost:8080': {
id: 'local:http://localhost:8080',
version: '1.0.0',
},
})
case 'wallet_invokeSnap':
if (args.params.request.method === 'antelope_getPublicKey') {
return Promise.resolve(
'PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63'
)
}
if (args.params.request.method === 'antelope_signTransaction') {
return Promise.resolve(
'SIG_K1_KfCdjsrTnx5cBpbA5cUdHZAsRYsnC9uKzuS1shFeqfMCfdZwX4PBm9pfHwGRT6ffz3eavhtkyNci5GoFozQAx8P8PBnDmj'
)
}
return Promise.resolve(null)
case 'web3_clientVersion':
return Promise.resolve(['MetaMask/v10.8.1'])
default:
return Promise.resolve(null)
}
}
}

const mockProvider = new MockMetaMaskInpageProvider()

export function setupEthereumMock() {
global.window = global.window || {}
global.window.ethereum = mockProvider as any
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"strict": true,
"target": "es2020"
},
"include": ["src/**/*"]
"include": ["src/**/*", "global.d.ts"]
}

0 comments on commit dff1c05

Please sign in to comment.