Skip to content

Commit 021bab2

Browse files
authored
Update js packages and Correct consts use (#2121)
# Goal The goal of this PR is regularly scheduled js package updates. This also switches the js const `TokenPerCapacity` to a function and uses the const from the chain instead.
1 parent 404a1e4 commit 021bab2

File tree

8 files changed

+1177
-421
lines changed

8 files changed

+1177
-421
lines changed

e2e/capacity/replenishment.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
getOrCreateGraphChangeSchema,
1313
CENTS,
1414
DOLLARS,
15-
TokenPerCapacity,
15+
getTokenPerCapacity,
1616
assertEvent,
1717
getCapacity,
1818
getNonce,
@@ -43,7 +43,7 @@ describe('Capacity Replenishment Testing: ', function () {
4343
describe('Capacity is replenished', function () {
4444
it('after new epoch', async function () {
4545
const totalStaked = 3n * DOLLARS;
46-
const expectedCapacity = totalStaked / TokenPerCapacity;
46+
const expectedCapacity = totalStaked / getTokenPerCapacity();
4747
const [stakeKeys, stakeProviderId] = await createAndStakeProvider('ReplFirst', totalStaked);
4848
const payload = JSON.stringify({ changeType: 1, fromId: 1, objectId: 2 });
4949
const call = ExtrinsicHelper.addOnChainMessage(stakeKeys, schemaId, payload);
@@ -111,7 +111,7 @@ describe('Capacity Replenishment Testing: ', function () {
111111
const payload = JSON.stringify({ changeType: 1, fromId: 1, objectId: 2 });
112112
const call = ExtrinsicHelper.addOnChainMessage(stakeKeys, schemaId, payload);
113113

114-
const expectedCapacity = (providerStakeAmt + userStakeAmt) / TokenPerCapacity;
114+
const expectedCapacity = (providerStakeAmt + userStakeAmt) / getTokenPerCapacity();
115115
const totalCapacity = (await getCapacity(stakeProviderId)).totalCapacityIssued.toBigInt();
116116
assert.equal(expectedCapacity, totalCapacity, `expected ${expectedCapacity} capacity, got ${totalCapacity}`);
117117

e2e/capacity/transactions.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
CENTS,
2121
DOLLARS,
2222
getOrCreateGraphChangeSchema,
23-
TokenPerCapacity,
23+
getTokenPerCapacity,
2424
assertEvent,
2525
getCurrentItemizedHash,
2626
getCurrentPaginatedHash,
@@ -182,12 +182,12 @@ describe('Capacity Transactions', function () {
182182

183183
const fee = getCapacityFee(eventMap);
184184
// assuming no other txns charged against capacity (b/c of async tests), this should be the maximum amount left.
185-
const maximumExpectedRemaining = stakedForMsa / TokenPerCapacity - fee;
185+
const maximumExpectedRemaining = stakedForMsa / getTokenPerCapacity() - fee;
186186

187187
const remaining = capacityStaked.remainingCapacity.toBigInt();
188188
assert(remaining <= maximumExpectedRemaining, `expected ${remaining} to be <= ${maximumExpectedRemaining}`);
189189
assert.equal(capacityStaked.totalTokensStaked.toBigInt(), stakedForMsa);
190-
assert.equal(capacityStaked.totalCapacityIssued.toBigInt(), stakedForMsa / TokenPerCapacity);
190+
assert.equal(capacityStaked.totalCapacityIssued.toBigInt(), stakedForMsa / getTokenPerCapacity());
191191
});
192192
});
193193

e2e/messages/addIPFSMessage.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('Add Offchain Message', function () {
105105
const f = ExtrinsicHelper.addIPFSMessage(keys, schemaId, ipfs_cid_64, ipfs_payload_len);
106106
const { target: event } = await f.fundAndSend(fundingSource);
107107

108-
assert.notEqual(event, undefined, 'should have returned a MessagesInBlock event');
108+
assert.notEqual(event, undefined, `should have returned a MessagesInBlock event, got: ${event?.toHuman()}`);
109109
});
110110

111111
it('should successfully retrieve added message and returned CID should have Base32 encoding', async function () {

0 commit comments

Comments
 (0)