-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test that returns referenda (call available)
- Loading branch information
Showing
6 changed files
with
314 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
110 changes: 110 additions & 0 deletions
110
src/services/test-helpers/mock/data/referendaEntries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Copyright 2017-2024 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate API Sidecar. | ||
// | ||
// Substrate API Sidecar is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import { polkadotMetadataRpcV1000001 } from '../../../../test-helpers/metadata/polkadotV1000001Metadata'; | ||
import { polkadotRegistryV1000001 } from '../../../../test-helpers/registries'; | ||
import { createApiWithAugmentations, TypeFactory } from '../../../../test-helpers/typeFactory'; | ||
|
||
const typeFactoryApiV9370 = createApiWithAugmentations(polkadotMetadataRpcV1000001); | ||
const factory = new TypeFactory(typeFactoryApiV9370); | ||
|
||
export const referendaEntries = () => { | ||
function createReferendumKey(key: string) { | ||
return factory.storageKey(key, 'u32', typeFactoryApiV9370.query.referenda.referendumInfoFor); | ||
} | ||
|
||
function createReferendumInfo( | ||
decisionDeposit: { who: string; amount: string } | null, | ||
submitted: number, | ||
deciding: { since: number; confirming: number | null } | null, | ||
enactment: { after: number } | { at: number }, | ||
) { | ||
const decisionDepositVal = | ||
decisionDeposit === null | ||
? null | ||
: { | ||
amount: | ||
decisionDeposit.amount === null | ||
? null | ||
: polkadotRegistryV1000001.createType('Balance', decisionDeposit.amount), | ||
who: polkadotRegistryV1000001.createType('AccountId', decisionDeposit.who), | ||
}; | ||
const decidingVal = | ||
deciding === null | ||
? null | ||
: { | ||
confirming: | ||
deciding.confirming === null | ||
? null | ||
: polkadotRegistryV1000001.createType('Compact<BlockNumber>', deciding.confirming), | ||
since: polkadotRegistryV1000001.createType('Compact<BlockNumber>', deciding.since), | ||
}; | ||
|
||
const onGoingRefInfo = { | ||
ongoing: { | ||
decisionDeposit: decisionDepositVal, | ||
enactment: enactment, | ||
submitted: polkadotRegistryV1000001.createType('Compact<BlockNumber>', submitted), | ||
deciding: decidingVal, | ||
}, | ||
}; | ||
const onGoingRefInfoEntry = polkadotRegistryV1000001.createType( | ||
'Option<PalletReferendaReferendumInfo>', | ||
onGoingRefInfo, | ||
); | ||
return onGoingRefInfoEntry; | ||
} | ||
|
||
const referendaEntries = []; | ||
for (let i = 0; i < 7; i++) { | ||
const referendaIds = ['890', '857', '841', '852', '872', '832', '888']; | ||
const referendumKey = createReferendumKey(referendaIds[i]); | ||
|
||
const decisionDeposit = [ | ||
null, | ||
{ who: '1EpEiYpWRAWmte4oPLtR5B1TZFxcBShBdjK4X9wWnq2KfLK', amount: '1000000000000000' }, | ||
{ who: '13sDzot2hwoEAzXJiNe3cBiMEq19XRqrS3DMAxt9jiSNKMkA', amount: '100000000000000' }, | ||
null, | ||
{ who: '13sDzot2hwoEAzXJiNe3cBiMEq19XRqrS3DMAxt9jiSNKMkA', amount: '100000000000000' }, | ||
{ who: '13sDzot2hwoEAzXJiNe3cBiMEq19XRqrS3DMAxt9jiSNKMkA', amount: '1000000000000000' }, | ||
{ who: '13RKipguGKrVofVeLgMJTThA8dzJvT6Ce1jycY4Nm8cwitsQ', amount: '100000000000000' }, | ||
]; | ||
const enactment = [ | ||
{ after: 10 }, | ||
{ after: 100 }, | ||
{ at: 21455000 }, | ||
{ after: 100 }, | ||
{ at: 21558000 }, | ||
{ after: 10 }, | ||
{ after: 10 }, | ||
]; | ||
const submitted = [21274219, 21171395, 21108384, 21157690, 21212837, 21070067, 21268637]; | ||
const deciding = [ | ||
null, | ||
null, | ||
{ since: 21109667, confirming: 21275466 }, | ||
null, | ||
{ since: 21214334, confirming: null }, | ||
{ since: 21071802, confirming: null }, | ||
{ since: 21269732, confirming: null }, | ||
]; | ||
const referendumInfo = createReferendumInfo(decisionDeposit[i], submitted[i], deciding[i], enactment[i]); | ||
|
||
referendaEntries.push([referendumKey, referendumInfo]); | ||
} | ||
|
||
return referendaEntries; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2017-2024 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate API Sidecar. | ||
// | ||
// Substrate API Sidecar is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import { polkadotRegistryV1000001 } from '../../../test-helpers/registries'; | ||
import block21275366 from './data/block21275366.json'; | ||
|
||
/** | ||
* Mock for Polkadot Block #21275366. | ||
*/ | ||
export const mockBlock21275366 = polkadotRegistryV1000001.createType('Block', block21275366); | ||
|
||
/** | ||
* BlockHash for Polkadot Block #21275366. | ||
*/ | ||
export const blockHash21275366 = polkadotRegistryV1000001.createType( | ||
'BlockHash', | ||
'0x109d98b52cd3c76801e6881ec5c746eac9a3d5e6017b0b2883a85d6b2907f5dc', | ||
); |
98 changes: 98 additions & 0 deletions
98
src/services/test-helpers/responses/pallets/fetchOnGoingReferenda21275366.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"at": { | ||
"hash": "0x109d98b52cd3c76801e6881ec5c746eac9a3d5e6017b0b2883a85d6b2907f5dc", | ||
"height": "21275366" | ||
}, | ||
"referenda": [ | ||
{ | ||
"id": "890", | ||
"decisionDeposit": null, | ||
"enactment": { | ||
"after": "10" | ||
}, | ||
"submitted": "21274219", | ||
"deciding": null | ||
}, | ||
{ | ||
"id": "857", | ||
"decisionDeposit": { | ||
"who": "1EpEiYpWRAWmte4oPLtR5B1TZFxcBShBdjK4X9wWnq2KfLK", | ||
"amount": "1000000000000000" | ||
}, | ||
"enactment": { | ||
"after": "100" | ||
}, | ||
"submitted": "21171395", | ||
"deciding": null | ||
}, | ||
{ | ||
"id": "841", | ||
"decisionDeposit": { | ||
"who": "13sDzot2hwoEAzXJiNe3cBiMEq19XRqrS3DMAxt9jiSNKMkA", | ||
"amount": "100000000000000" | ||
}, | ||
"enactment": { | ||
"at": "21455000" | ||
}, | ||
"submitted": "21108384", | ||
"deciding": { | ||
"since": "21109667", | ||
"confirming": "21275466" | ||
} | ||
}, | ||
{ | ||
"id": "852", | ||
"decisionDeposit": null, | ||
"enactment": { | ||
"after": "100" | ||
}, | ||
"submitted": "21157690", | ||
"deciding": null | ||
}, | ||
{ | ||
"id": "872", | ||
"decisionDeposit": { | ||
"who": "13sDzot2hwoEAzXJiNe3cBiMEq19XRqrS3DMAxt9jiSNKMkA", | ||
"amount": "100000000000000" | ||
}, | ||
"enactment": { | ||
"at": "21558000" | ||
}, | ||
"submitted": "21212837", | ||
"deciding": { | ||
"since": "21214334", | ||
"confirming": null | ||
} | ||
}, | ||
{ | ||
"id": "832", | ||
"decisionDeposit": { | ||
"who": "13sDzot2hwoEAzXJiNe3cBiMEq19XRqrS3DMAxt9jiSNKMkA", | ||
"amount": "1000000000000000" | ||
}, | ||
"enactment": { | ||
"after": "10" | ||
}, | ||
"submitted": "21070067", | ||
"deciding": { | ||
"since": "21071802", | ||
"confirming": null | ||
} | ||
}, | ||
{ | ||
"id": "888", | ||
"decisionDeposit": { | ||
"who": "13RKipguGKrVofVeLgMJTThA8dzJvT6Ce1jycY4Nm8cwitsQ", | ||
"amount": "100000000000000" | ||
}, | ||
"enactment": { | ||
"after": "10" | ||
}, | ||
"submitted": "21268637", | ||
"deciding": { | ||
"since": "21269732", | ||
"confirming": null | ||
} | ||
} | ||
] | ||
} |