Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
substrate-api-sidecar
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
substrate-api-sidecar
Commits
8f1c9f03
Unverified
Commit
8f1c9f03
authored
3 years ago
by
Tarik Gul
Browse files
Options
Downloads
Patches
Plain Diff
fix: cleanup tests
parent
872418cd
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/services/blocks/BlocksService.spec.ts
+51
-38
51 additions, 38 deletions
src/services/blocks/BlocksService.spec.ts
with
51 additions
and
38 deletions
src/services/blocks/BlocksService.spec.ts
+
51
−
38
View file @
8f1c9f03
...
@@ -3,6 +3,7 @@ import { ApiPromise } from '@polkadot/api';
...
@@ -3,6 +3,7 @@ import { ApiPromise } from '@polkadot/api';
import
{
AugmentedConst
}
from
'
@polkadot/api/types/consts
'
;
import
{
AugmentedConst
}
from
'
@polkadot/api/types/consts
'
;
import
{
RpcPromiseResult
}
from
'
@polkadot/api/types/rpc
'
;
import
{
RpcPromiseResult
}
from
'
@polkadot/api/types/rpc
'
;
import
{
GenericExtrinsic
}
from
'
@polkadot/types
'
;
import
{
GenericExtrinsic
}
from
'
@polkadot/types
'
;
import
{
AbstractInt
}
from
'
@polkadot/types/codec/AbstractInt
'
;
import
{
GenericCall
}
from
'
@polkadot/types/generic
'
;
import
{
GenericCall
}
from
'
@polkadot/types/generic
'
;
import
{
import
{
BalanceOf
,
BalanceOf
,
...
@@ -185,49 +186,61 @@ describe('BlocksService', () => {
...
@@ -185,49 +186,61 @@ describe('BlocksService', () => {
calcFee
?.
calc_fee
(
BigInt
(
941325000000
),
1247
,
BigInt
(
125000000
))
calcFee
?.
calc_fee
(
BigInt
(
941325000000
),
1247
,
BigInt
(
125000000
))
).
toBe
(
'
1257000075
'
);
).
toBe
(
'
1257000075
'
);
});
});
});
describe
(
'
BlocksService.getDecorateAndExtractWeight
'
,
()
=>
{
const
baseWeight
=
(
125000000
as
unknown
)
as
AbstractInt
;
it
(
'
Should extract extrinsicBaseWeight correctly when were in a non-polkadot the chain and the runtime is the same as the api
'
,
async
()
=>
{
const
baseWeightObject
=
await
blocksService
[
'
getDecorateAndExtractWeight
'
](
mockApi
,
(
'
0xParentHash
'
as
unknown
)
as
Hash
,
16
,
'
westend
'
);
it
(
'
Should fill the cache with decorated and runtimeVersion data when running on a Non-Polkadot-Kusama chain
'
,
async
()
=>
{
expect
(
// (mockApi.runtimeVersion
BigInt
(
// .specName as unknown) = polkadotRegistry.createType('Text', 'westend');
baseWeightObject
[
'
16
'
].
decorated
.
consts
.
system
.
extrinsicBaseWeight
// await blocksService['createCalcFee'](
)
// mockApi,
).
toBe
(
BigInt
(
baseWeight
));
// ('0xParentHash' as unknown) as Hash,
});
// mockBlock789629
// );
it
(
'
Should extract extrinsicBaseWeight correctly when the block runtimeVersion matches the api
'
,
async
()
=>
{
// /**
const
baseWeightObject
=
await
blocksService
[
// * This checks to make sure the cache is updated.
'
getDecorateAndExtractWeight
'
// */
](
mockApi
,
(
'
0xParentHash
'
as
unknown
)
as
Hash
,
16
,
'
polkadot
'
);
// expect(that.cache.decorated).toBeTruthy();
// /**
expect
(
// * Check runtimeVersion. Westend's actual version might be different
BigInt
(
// * but because we are checking just createCalcFee we just need to make
baseWeightObject
[
'
16
'
].
decorated
.
consts
.
system
.
extrinsicBaseWeight
// * sure it stores the mockApi block's default runtime.
)
// */
).
toBe
(
BigInt
(
baseWeight
));
// expect(that.cache.runtimeVersion).toBe(16);
// (mockApi.runtimeVersion
// .specName as unknown) = polkadotRegistry.createType('Text', 'polkadot');
});
});
it
(
'
Should
cache the correct block runtime when different from the api runtime
'
,
async
()
=>
{
it
(
'
Should
extract extrinsicBaseWeight correctly using expandMetadata when runtimes do not match
'
,
async
()
=>
{
/**
/**
* The mockApi take runtimeVersion is shared between the api and block
* The default mockApi is runtimeVersion is 16 so we are testing it against 20
* so updating the mockApi runtimeVersion will update the version to be cached
* from the block.
*/
*/
// (mockApi.runtimeVersion
const
baseWeightObject
=
await
blocksService
[
// .specVersion as unknown) = polkadotRegistry.createType('u32', 20);
'
getDecorateAndExtractWeight
'
// (mockApi.runtimeVersion
](
mockApi
,
(
'
0xParentHash
'
as
unknown
)
as
Hash
,
20
,
'
westend
'
);
// .specName as unknown) = polkadotRegistry.createType('Text', 'westend');
// await blocksService['createCalcFee'](
expect
(
// mockApi,
BigInt
(
// ('0xParentHash' as unknown) as Hash,
baseWeightObject
[
'
20
'
].
decorated
.
consts
.
system
.
extrinsicBaseWeight
// mockBlock789629
)
// );
).
toBe
(
BigInt
(
baseWeight
));
// expect(that.cache.runtimeVersion).toBe(20);
});
// (mockApi.runtimeVersion
// .specVersion as unknown) = polkadotRegistry.createType('u32', 16);
it
(
'
Should extract blockWeights correctly
'
,
async
()
=>
{
// (mockApi.runtimeVersion
const
baseWeightObject
=
await
blocksService
[
// .specName as unknown) = polkadotRegistry.createType('Text', 'polkadot');
'
getDecorateAndExtractWeight
'
](
mockApi
,
(
'
0xParentHash
'
as
unknown
)
as
Hash
,
28
,
'
polkadot
'
);
expect
(
BigInt
(
baseWeightObject
[
'
28
'
].
decorated
.
consts
.
system
.
blockWeights
?.
perClass
.
normal
.
baseExtrinsic
)
).
toBe
(
BigInt
(
baseWeight
));
});
});
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment