Skip to content

Commit 95b4bb3

Browse files
authored
Merge pull request #145 from Concordium/remove-old-client-from-tests
Remove old client from tests
2 parents ee5de69 + 39a2ab3 commit 95b4bb3

File tree

7 files changed

+589
-134
lines changed

7 files changed

+589
-134
lines changed

packages/nodejs/test/clientV2.test.ts

Lines changed: 31 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import { serializeAccountTransactionPayload } from '@concordium/common-sdk/src';
1818
import {
1919
getModuleBuffer,
2020
getIdentityInput,
21-
getNodeClient as getNodeClientV1,
22-
getNodeClientV2,
21+
getNodeClient,
2322
} from './testHelpers';
2423
import * as ed from '@noble/ed25519';
2524
import * as expected from './resources/expectedJsons';
@@ -49,8 +48,7 @@ export function getNodeClientWeb(
4948
return new v1.ConcordiumGRPCClient(transport);
5049
}
5150

52-
const clientV1 = getNodeClientV1('node.testnet.concordium.com', 10000);
53-
const clientV2 = getNodeClientV2();
51+
const clientV2 = getNodeClient();
5452
const clientWeb = getNodeClientWeb();
5553

5654
const testAccount = new v1.AccountAddress(
@@ -174,66 +172,26 @@ test.each([clientV2, clientWeb])(
174172
test.each([clientV2, clientWeb])(
175173
'accountInfo implementations is the same',
176174
async (client) => {
177-
const oldReg = await clientV1.getAccountInfo(
178-
testAccount,
179-
testBlockHash
180-
);
181-
const newReg = await client.getAccountInfo(testAccount, testBlockHash);
182-
183-
const oldCredId = await clientV1.getAccountInfo(
184-
testCredId,
185-
testBlockHash
186-
);
187-
const newCredId = await client.getAccountInfo(
188-
testCredId,
189-
testBlockHash
190-
);
191-
192-
const oldBaker = await clientV1.getAccountInfo(
193-
testAccBaker,
194-
testBlockHash
195-
);
196-
const newBaker = await client.getAccountInfo(
197-
testAccBaker,
198-
testBlockHash
199-
);
200-
201-
const oldDeleg = await clientV1.getAccountInfo(
202-
testAccDeleg,
203-
testBlockHash
204-
);
205-
const newDeleg = await client.getAccountInfo(
206-
testAccDeleg,
207-
testBlockHash
208-
);
209-
210-
expect(oldReg).toEqual(newReg);
211-
expect(oldCredId).toEqual(newCredId);
212-
expect(oldDeleg).toEqual(newDeleg);
213-
expect(oldBaker).toEqual(newBaker);
175+
const regular = await client.getAccountInfo(testAccount, testBlockHash);
176+
const credId = await client.getAccountInfo(testCredId, testBlockHash);
177+
const baker = await client.getAccountInfo(testAccBaker, testBlockHash);
178+
const deleg = await client.getAccountInfo(testAccDeleg, testBlockHash);
179+
180+
expect(regular).toEqual(expected.regularAccountInfo);
181+
expect(credId).toEqual(expected.credIdAccountInfo);
182+
expect(baker).toEqual(expected.bakerAccountInfo);
183+
expect(deleg).toEqual(expected.delegatorAccountInfo);
214184
}
215185
);
216186

217187
test.each([clientV2, clientWeb])(
218188
'getChainParameters corresponds to GetBlockSummary subset',
219189
async (client) => {
220-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
221-
const blockSummary: any = await clientV1.getBlockSummary(testBlockHash);
222-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
223-
const chainParameters: any = await client.getBlockChainParameters(
190+
const chainParameters = await client.getBlockChainParameters(
224191
testBlockHash
225192
);
226193

227-
const foundationAccount = (
228-
await client.getAccountInfo(
229-
blockSummary.updates.chainParameters.foundationAccountIndex
230-
)
231-
).accountAddress;
232-
expect(chainParameters.foundationAccount).toEqual(foundationAccount);
233-
blockSummary.updates.chainParameters.foundationAccountIndex = undefined;
234-
chainParameters.foundationAccount = undefined;
235-
236-
expect(blockSummary.updates.chainParameters).toEqual(chainParameters);
194+
expect(chainParameters).toEqual(expected.chainParameters);
237195
}
238196
);
239197

@@ -242,43 +200,29 @@ test.each([clientV2, clientWeb])(
242200
async (client) => {
243201
const oldBlockHash =
244202
'ed2507c4d05108038741e87757ab1c3acdeeb3327027cd2972666807c9c4a20d';
245-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
246-
const blockSummary: any = await clientV1.getBlockSummary(oldBlockHash);
247-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
248-
const chainParameters: any = await client.getBlockChainParameters(
203+
const oldChainParameters = await client.getBlockChainParameters(
249204
oldBlockHash
250205
);
251206

252-
const foundationAccount = (
253-
await client.getAccountInfo(
254-
blockSummary.updates.chainParameters.foundationAccountIndex
255-
)
256-
).accountAddress;
257-
expect(chainParameters.foundationAccount).toEqual(foundationAccount);
258-
blockSummary.updates.chainParameters.foundationAccountIndex = undefined;
259-
chainParameters.foundationAccount = undefined;
260-
261-
expect(blockSummary.updates.chainParameters).toEqual(chainParameters);
207+
expect(oldChainParameters).toEqual(expected.oldChainParameters);
262208
}
263209
);
264210

265211
test.each([clientV2, clientWeb])(
266212
'getPoolInfo corresponds to getPoolStatus with a bakerId',
267213
async (client) => {
268-
const oldStatus = await clientV1.getPoolStatus(testBlockHash, 1n);
269-
const newStatus = await client.getPoolInfo(1n, testBlockHash);
214+
const bakerPoolStatus = await client.getPoolInfo(1n, testBlockHash);
270215

271-
expect(oldStatus).toEqual(newStatus);
216+
expect(bakerPoolStatus).toEqual(expected.bakerPoolStatus);
272217
}
273218
);
274219

275220
test.each([clientV2, clientWeb])(
276221
'getPassiveDelegationInfo corresponds to getPoolStatus with no bakerId',
277222
async (client) => {
278-
const oldStatus = await clientV1.getPoolStatus(testBlockHash);
279-
const newStatus = await client.getPassiveDelegationInfo(testBlockHash);
223+
const status = await client.getPassiveDelegationInfo(testBlockHash);
280224

281-
expect(oldStatus).toEqual(newStatus);
225+
expect(status).toEqual(expected.passiveDelegationStatus);
282226
}
283227
);
284228
test.each([clientV2, clientWeb])(
@@ -287,13 +231,10 @@ test.each([clientV2, clientWeb])(
287231
const changeHash =
288232
'2aa7c4a54ad403a9f9b48de2469e5f13a64c95f2cf7a8e72c0f9f7ae0718f642';
289233
const changedAccount = 1879n;
290-
const oldStatus = await clientV1.getPoolStatus(
291-
changeHash,
292-
changedAccount
293-
);
294-
const newStatus = await client.getPoolInfo(changedAccount, changeHash);
295234

296-
expect(oldStatus).toEqual(newStatus);
235+
const poolStatus = await client.getPoolInfo(changedAccount, changeHash);
236+
237+
expect(poolStatus).toEqual(expected.bakerPoolStatusWithPendingChange);
297238
}
298239
);
299240

@@ -396,10 +337,9 @@ test.each([clientV2, clientWeb])(
396337
parameter: undefined,
397338
energy: 30000n,
398339
};
399-
const resultV1 = await clientV1.invokeContract(context, testBlockHash);
400-
const resultV2 = await client.invokeContract(context, testBlockHash);
340+
const result = await client.invokeContract(context, testBlockHash);
401341

402-
expect(resultV2).toEqual(resultV1);
342+
expect(result).toEqual(expected.invokeContractResult);
403343
}
404344
);
405345

@@ -665,10 +605,9 @@ test.each([clientV2, clientWeb])('getAnonymityRevokers', async (client) => {
665605
});
666606

667607
test.each([clientV2, clientWeb])('getBlocksAtHeight', async (client) => {
668-
const blocksV1 = await clientV1.getBlocksAtHeight(1n);
669-
const blocksV2 = await client.getBlocksAtHeight(1n);
608+
const blocks = await client.getBlocksAtHeight(1n);
670609

671-
expect(blocksV1[0]).toEqual(blocksV2[0]);
610+
expect(blocks).toEqual(expected.blocksAtHeight);
672611
});
673612

674613
test.each([clientV2, clientWeb])(
@@ -682,23 +621,22 @@ test.each([clientV2, clientWeb])(
682621
const expectedBlock =
683622
'956c3bc5c9d10449e13686a4cc69e8bc7dee450608866242075a6ce37331187c';
684623
const blocks = await client.getBlocksAtHeight(request);
624+
685625
expect(blocks[0]).toEqual(expectedBlock);
686626
}
687627
);
688628

689629
test.each([clientV2, clientWeb])('getBlockInfo', async (client) => {
690-
const blockInfoV1 = await clientV1.getBlockInfo(testBlockHash);
691-
const blockInfoV2 = await client.getBlockInfo(testBlockHash);
630+
const blockInfo = await client.getBlockInfo(testBlockHash);
692631

693-
expect(blockInfoV2).toEqual(blockInfoV1);
632+
expect(blockInfo).toEqual(expected.blockInfo);
694633
});
695634

696635
test.each([clientV2, clientWeb])('getBakerList', async (client) => {
697636
const bakerAsyncIterable = client.getBakerList(testBlockHash);
698-
const bakersV2 = await asyncIterableToList(bakerAsyncIterable);
699-
const bakersV1 = await clientV1.getBakerList(testBlockHash);
637+
const bakers = await asyncIterableToList(bakerAsyncIterable);
700638

701-
expect(bakersV2).toEqual(bakersV1);
639+
expect(bakers).toEqual(expected.bakers);
702640
});
703641

704642
test.each([clientV2, clientWeb])('getPoolDelegators', async (client) => {

packages/nodejs/test/events.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as expected from './resources/expectedJsons';
22
import { asyncIterableToList } from '@concordium/common-sdk/src/util';
3-
import { getNodeClientV2 } from './testHelpers';
3+
import { getNodeClient } from './testHelpers';
44

5-
const client = getNodeClientV2();
5+
const client = getNodeClient();
66

77
// AccountCreated
88
test('accountCreated', async () => {

packages/nodejs/test/manualTests.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {
44
buildBasicAccountSigner,
55
signTransaction,
66
} from '@concordium/common-sdk';
7-
import { getNodeClientV2 } from '../test/testHelpers';
7+
import { getNodeClient } from '../test/testHelpers';
88

9-
const clientV2 = getNodeClientV2();
9+
const client = getNodeClient();
1010

1111
const testAccount = new v1.AccountAddress(
1212
'3kBx2h5Y2veb4hZgAJWPrr8RyQESKm5TjzF3ti1QQ4VSYLwK1G'
@@ -20,7 +20,7 @@ const senderAccountPrivateKey =
2020

2121
describe.skip('Manual test suite', () => {
2222
test('waitForTransactionFinalization', async () => {
23-
const nonce = (await clientV2.getNextAccountNonce(senderAccount)).nonce;
23+
const nonce = (await client.getNextAccountNonce(senderAccount)).nonce;
2424

2525
// Create local transaction
2626
const header: v1.AccountTransactionHeader = {
@@ -45,12 +45,12 @@ describe.skip('Manual test suite', () => {
4545
signer
4646
);
4747

48-
const transactionHash = await clientV2.sendAccountTransaction(
48+
const transactionHash = await client.sendAccountTransaction(
4949
accountTransaction,
5050
signature
5151
);
5252

53-
const blockHash = await clientV2.waitForTransactionFinalization(
53+
const blockHash = await client.waitForTransactionFinalization(
5454
transactionHash,
5555
undefined
5656
);
@@ -62,31 +62,31 @@ describe.skip('Manual test suite', () => {
6262
// Requires a node that allows performing banPeer/unbanPeer/getBannedPeers
6363
test('Ban/Unban peer is reflected in ban list', async () => {
6464
const randomIp = '229.249.155.177';
65-
await clientV2.banPeer(randomIp);
66-
let peers = await clientV2.getBannedPeers();
65+
await client.banPeer(randomIp);
66+
let peers = await client.getBannedPeers();
6767
expect(peers).toContainEqual(randomIp);
68-
await clientV2.unbanPeer(randomIp);
69-
peers = await clientV2.getBannedPeers();
68+
await client.unbanPeer(randomIp);
69+
peers = await client.getBannedPeers();
7070
expect(peers).not.toContainEqual(randomIp);
7171
}, 750000);
7272

7373
// Requires a node that allows performing peerConnect/peerDisconnect/getPeersInfo
7474
test('Connecting/disconnecting peer is reflected in Peers info list', async () => {
75-
const peer = (await clientV2.client.getPeersInfo(v2.Empty).response)
75+
const peer = (await client.client.getPeersInfo(v2.Empty).response)
7676
.peers[0].socketAddress;
7777
if (!peer || !peer.ip || !peer.port) {
7878
throw new Error('missing peer');
7979
}
80-
await clientV2.peerDisconnect(peer.ip.value, peer.port.value);
80+
await client.peerDisconnect(peer.ip.value, peer.port.value);
8181
await new Promise((r) => setTimeout(r, 10000));
8282
let updatedPeers = (
83-
await clientV2.client.getPeersInfo(v2.Empty).response
83+
await client.client.getPeersInfo(v2.Empty).response
8484
).peers.map((x) => x.socketAddress);
8585
expect(updatedPeers).not.toContainEqual(peer);
86-
await clientV2.peerConnect(peer.ip.value, peer.port.value);
86+
await client.peerConnect(peer.ip.value, peer.port.value);
8787
await new Promise((r) => setTimeout(r, 10000));
8888
updatedPeers = (
89-
await clientV2.client.getPeersInfo(v2.Empty).response
89+
await client.client.getPeersInfo(v2.Empty).response
9090
).peers.map((x) => x.socketAddress);
9191
expect(updatedPeers).toContainEqual(peer);
9292
}, 750000);

packages/nodejs/test/rejectReasons.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as expected from './resources/expectedJsons';
22
import { asyncIterableToList } from '@concordium/common-sdk/src/util';
3-
import { getNodeClientV2 } from './testHelpers';
3+
import { getNodeClient } from './testHelpers';
44

5-
const client = getNodeClientV2();
5+
const client = getNodeClient();
66

77
// EncryptedAmountSelfTransfer
88
test('EncryptedAmountSelfTransfer', async () => {

0 commit comments

Comments
 (0)