Remove old test infrastructure (#5070)
This commit is contained in:
@@ -12,7 +12,7 @@ import { MockProvider } from '@polkadot/rpc-provider/mock';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
|
||||
import { SingleAccountSigner } from '../test/util';
|
||||
import { SingleAccountSigner } from '../test';
|
||||
import { ApiPromise } from '.';
|
||||
|
||||
const TRANSFER_SIG = '0xcc277eb341d3801c08f149508221583fa3185cc3944e6cb376cd061640305edd7dc24dfd754adb24768f1d8547389b7720e6f626bc81f5593fba1141e7f7ba07';
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2017-2022 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { jest } from '@jest/globals';
|
||||
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
|
||||
describe.skip('misc online tests', (): void => {
|
||||
let api: ApiPromise;
|
||||
|
||||
beforeEach(async () => {
|
||||
jest.setTimeout(30000);
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
// const provider = new WsProvider('wss://kusama-rpc.polkadot.io');
|
||||
const provider = new WsProvider('wss://westend-rpc.polkadot.io/');
|
||||
|
||||
api = await ApiPromise.create({ provider });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await api.disconnect();
|
||||
});
|
||||
|
||||
it('expose rpc and rx definition', (): void => {
|
||||
console.error(api.rpc.payment.queryFeeDetails.meta);
|
||||
console.error(api.rx.rpc.chain.getBlock.meta);
|
||||
});
|
||||
|
||||
it.skip('retrieves balances correctly', async (): Promise<void> => {
|
||||
console.error(JSON.stringify(
|
||||
await api.query.system.account('FPzukZw2mphWsXDqdkNzLaxnanjZEWH9i2vqwobTdtde5me')
|
||||
));
|
||||
console.error(JSON.stringify(
|
||||
await api.query.system.account('HUewJvzVuEeyaxH2vx9XiyAPKrpu1Zj5r5Pi9VrGiBVty7q')
|
||||
));
|
||||
});
|
||||
|
||||
it.skip('handles map keys', async (): Promise<void> => {
|
||||
console.time('map.keys');
|
||||
|
||||
const keys = await api.query.system.account.keys();
|
||||
|
||||
console.error('# keys', keys.length);
|
||||
|
||||
console.timeEnd('map.keys');
|
||||
});
|
||||
|
||||
it.skip('handles map entries', async (): Promise<void> => {
|
||||
console.time('map.entries');
|
||||
|
||||
const entries = await api.query.system.account.entries(); // api.query.indices.accounts.entries();
|
||||
|
||||
console.error('# entries', entries.length);
|
||||
|
||||
console.timeEnd('map.entries');
|
||||
});
|
||||
|
||||
it.skip('handles doublemap entries', async (): Promise<void> => {
|
||||
const activeEra = await api.query.staking.activeEra();
|
||||
|
||||
console.error(JSON.stringify(
|
||||
await api.query.staking.erasStakers.entries(activeEra.unwrapOrDefault().index)
|
||||
));
|
||||
});
|
||||
|
||||
it.skip('does something in society', async (): Promise<void> => {
|
||||
console.error(JSON.stringify(
|
||||
await api.query.society.defenderVotes('Dab4bfYTZRUDMWjYAUQuFbDreQ9mt7nULWu3Dw7jodbzVe9')
|
||||
));
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
|
||||
import { SubmittableResult } from '../..';
|
||||
import { SubmittableResult } from '..';
|
||||
|
||||
// log all events for the transfers, calling done() when finalized
|
||||
export const logEvents = (done: () => Record<string, unknown>): (r: SubmittableResult) => void =>
|
||||
@@ -1,236 +0,0 @@
|
||||
// Copyright 2017-2022 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Enum, Struct } from '@polkadot/types';
|
||||
import type { Option } from '@polkadot/types/codec';
|
||||
import type { AccountId, AccountIndex, AccountInfo, Address, Balance, BlockNumber, Index } from '@polkadot/types/interfaces';
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
import { memo } from '@polkadot/rpc-core';
|
||||
|
||||
interface VestingInfo extends Struct {
|
||||
readonly locked: Balance;
|
||||
readonly perBlock: Balance;
|
||||
readonly startingBlock: BlockNumber;
|
||||
}
|
||||
|
||||
interface SignedBalance extends Enum {
|
||||
readonly isPositive: boolean;
|
||||
readonly asPositive: Balance;
|
||||
readonly isNegative: boolean;
|
||||
readonly asNegative: Balance;
|
||||
}
|
||||
|
||||
export interface EQDeriveBalancesAll {
|
||||
freeBalance: Balance;
|
||||
reservedBalance: Balance;
|
||||
vestingLocked: Balance;
|
||||
lockedBalance: Balance;
|
||||
accountId: AccountId;
|
||||
accountNonce: Index;
|
||||
lockedBreakdown: unknown[];
|
||||
}
|
||||
|
||||
type Result = [Balance, Balance, Balance, Index];
|
||||
|
||||
type RawResult = [
|
||||
SignedBalance,
|
||||
Option<Balance>,
|
||||
Option<VestingInfo>,
|
||||
AccountInfo
|
||||
];
|
||||
|
||||
type EQDeriveBalancesQuery = (address: AccountIndex | AccountId | Address | string) => Observable<EQDeriveBalancesAll>;
|
||||
|
||||
const typesBundle = {
|
||||
spec: {
|
||||
Equilibrium: {
|
||||
derives: {
|
||||
balances: {
|
||||
all: (
|
||||
instanceId: string,
|
||||
api: ApiInterfaceRx
|
||||
): EQDeriveBalancesQuery =>
|
||||
memo(
|
||||
instanceId,
|
||||
(address: AccountIndex | AccountId | Address | string) =>
|
||||
api.derive.accounts.accountId(address).pipe(
|
||||
switchMap(
|
||||
(accountId): Observable<[AccountId, Result]> =>
|
||||
accountId
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
api
|
||||
.queryMulti([
|
||||
[api.query.balances.account, [accountId, 'EQ']],
|
||||
[api.query.eqVesting.vested, accountId],
|
||||
[api.query.eqVesting.vesting, accountId],
|
||||
[api.query.system.account, accountId]
|
||||
])
|
||||
.pipe(
|
||||
map(
|
||||
(raw): Result => {
|
||||
if (raw.length < 4) {
|
||||
throw new Error('4 members expected');
|
||||
}
|
||||
|
||||
const res = raw as RawResult;
|
||||
const freeBalance = res[0].asPositive;
|
||||
|
||||
let reservedBalance = api.registry.createType(
|
||||
'Balance'
|
||||
);
|
||||
|
||||
let vestingLocked = api.registry.createType(
|
||||
'Balance'
|
||||
);
|
||||
|
||||
if (res[1].isSome && res[2].isSome) {
|
||||
const vested = res[1].unwrap();
|
||||
const info = res[2].unwrap();
|
||||
|
||||
vestingLocked = info.locked;
|
||||
|
||||
reservedBalance = api.registry.createType(
|
||||
'Balance',
|
||||
vestingLocked.sub(vested)
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
freeBalance,
|
||||
reservedBalance,
|
||||
vestingLocked,
|
||||
res[3].nonce
|
||||
];
|
||||
}
|
||||
)
|
||||
)
|
||||
])
|
||||
: of([
|
||||
api.registry.createType('AccountId'),
|
||||
[
|
||||
api.registry.createType('Balance'),
|
||||
api.registry.createType('Balance'),
|
||||
api.registry.createType('Balance'),
|
||||
api.registry.createType('Index')
|
||||
]
|
||||
])
|
||||
),
|
||||
map(
|
||||
([
|
||||
accountId,
|
||||
[
|
||||
freeBalance,
|
||||
reservedBalance,
|
||||
vestingLocked,
|
||||
accountNonce
|
||||
]
|
||||
]): EQDeriveBalancesAll => ({
|
||||
accountId,
|
||||
accountNonce,
|
||||
freeBalance,
|
||||
lockedBalance: vestingLocked,
|
||||
lockedBreakdown: [],
|
||||
reservedBalance,
|
||||
vestingLocked
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
types: [
|
||||
{
|
||||
minmax: [0, undefined],
|
||||
types: {
|
||||
Balance: 'u64',
|
||||
BalanceOf: 'Balance',
|
||||
BalancesAggregate: {
|
||||
total_debt: 'Balance',
|
||||
total_issuance: 'Balance'
|
||||
},
|
||||
BlockNumber: 'u64',
|
||||
Currency: {
|
||||
_enum: ['Unknown', 'Usd', 'EQ', 'Eth', 'Btc', 'Eos', 'Dot']
|
||||
},
|
||||
DataPoint: {
|
||||
account_id: 'AccountId',
|
||||
block_number: 'BlockNumber',
|
||||
price: 'u64',
|
||||
timestamp: 'u64'
|
||||
},
|
||||
FixedI64: 'i64',
|
||||
Keys: 'SessionKeys3',
|
||||
LookupSource: 'AccountId',
|
||||
PricePeriod: {
|
||||
_enum: ['Min', 'TenMin', 'Hour', 'FourHour', 'Day']
|
||||
},
|
||||
PricePoint: {
|
||||
block_number: 'BlockNumber',
|
||||
data_points: 'Vec<DataPoint>',
|
||||
price: 'u64',
|
||||
timestamp: 'u64'
|
||||
},
|
||||
ReinitRequest: {
|
||||
account: 'AccountId',
|
||||
authority_index: 'AuthIndex',
|
||||
block_num: 'BlockNumber',
|
||||
validators_len: 'u32'
|
||||
},
|
||||
SignedBalance: {
|
||||
_enum: {
|
||||
Negative: 'Balance',
|
||||
Positive: 'Balance'
|
||||
}
|
||||
},
|
||||
TotalAggregates: {
|
||||
collateral: 'Balance',
|
||||
debt: 'Balance'
|
||||
},
|
||||
TransferReason: {
|
||||
_enum: [
|
||||
'Common',
|
||||
'InterestFee',
|
||||
'MarginCall',
|
||||
'BailsmenRedistribution',
|
||||
'TreasuryEqBuyout',
|
||||
'TreasuryBuyEq'
|
||||
]
|
||||
},
|
||||
UserGroup: {
|
||||
_enum: ['Unknown', 'Balances', 'Bailsman']
|
||||
},
|
||||
VestingInfo: {
|
||||
locked: 'Balance',
|
||||
perBlock: 'Balance',
|
||||
startingBlock: 'BlockNumber'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function createApi (): Promise<ApiPromise> {
|
||||
jest.setTimeout(30000);
|
||||
const provider = new WsProvider('wss://tge.equilibrium.io');
|
||||
|
||||
return ApiPromise.create({ provider, typesBundle });
|
||||
}
|
||||
|
||||
describe.skip('equilibrium api', () => {
|
||||
it.skip('does not fail on derive.balances.all', async () => {
|
||||
const api = await createApi();
|
||||
|
||||
await api.derive.balances.all(
|
||||
'5DnoYz3koaRcMZ9Hj4FmQ2nNRKQfS73yBmEzzM9SsPn9cLtb'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user