Skip to content

Commit

Permalink
add 942057 migration scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksandre committed Jun 9, 2023
1 parent cd2a1cb commit c656b7b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions tests/src/migrations/942057-appPromotion/collect-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chainql --tla-str=chainUrl=ws://127.0.0.1:9944 stakersParser.jsonnet > output.json
3 changes: 3 additions & 0 deletions tests/src/migrations/942057-appPromotion/collectData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {spawnSync} from 'child_process';

export const collectData = () => spawnSync('sh', ['./collect-data.sh']);
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const main = async(options: { wsEndpoint: string; donorSeed: string } = {

const failedBlocks: bigint[] = [];
let isSuccess = true;
await helper.wait.newBlocks(1);

for(const b of filteredBlocks) {
if(((await api.query.appPromotion.pendingUnstake(b)).toJSON() as any[]).length != 0) {
Expand Down
12 changes: 12 additions & 0 deletions tests/src/migrations/942057-appPromotion/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Migration} from '../../util/frankensteinMigrate';
import {collectData} from './collectData';
import {migrateLockedToFreeze} from './lockedToFreeze';

export const migration: Migration = {
async before() {
await collectData();
},
async after() {
await migrateLockedToFreeze();
},
};
11 changes: 1 addition & 10 deletions tests/src/migrations/942057-appPromotion/lockedToFreeze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function customNumberParser(value: any) {
return isInteger(value) ? BigInt(value) : parseFloat(value);
}

const main = async(options: { wsEndpoint: string; donorSeed: string } = {
export const migrateLockedToFreeze = async(options: { wsEndpoint: string; donorSeed: string } = {
wsEndpoint: WS_ENDPOINT,
donorSeed: DONOR_SEED,
}) => {
Expand Down Expand Up @@ -254,12 +254,3 @@ const testChainqlData = (data: any) => {
}
console.log('Chainql data correct');
};

main({
wsEndpoint: process.env.WS_RPC!,
donorSeed: process.env.SUPERUSER_SEED!,
}).then(() => process.exit(0))
.catch((e) => {
console.error(e);
process.exit(1);
});

0 comments on commit c656b7b

Please sign in to comment.