Skip to content
9 changes: 7 additions & 2 deletions js/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const TESTS = (api: ApiPromise, config: ExtrinsicConfig): Extrinsic[] => {
args: [
config.alice.address,
ASSET_ID_A,
PINT.mul(new BN(ASSET_ID_A_UNITS)),
PINT.mul(ASSET_ID_A_UNITS).mul(new BN(3)),
0,
],
},
Expand Down Expand Up @@ -532,5 +532,10 @@ const TESTS = (api: ApiPromise, config: ExtrinsicConfig): Extrinsic[] => {

// main
(async () => {
await Runner.run(TESTS);
try {
await Runner.run(TESTS);
} catch (error) {
throw error;
process.exit(1);
}
})();
19 changes: 6 additions & 13 deletions js/e2e/src/extrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ export class Extrinsic {
*/
public async propose(
proposals: Record<string, string>,
finished: string[],
errors: string[],
queue: Extrinsic[],
config: ExtrinsicConfig
): Promise<void | string> {
Expand Down Expand Up @@ -304,18 +302,18 @@ export class Extrinsic {
nonce: number
): Promise<void | string> {
console.log(`-> queue extrinsic ${nonce}: ${this.id}...`);
const tx = await this.build();
const tx = await this.build().catch((err) => {
console.log(
`====> Error: extrinsic build failed ${this.id} failed: ${err}`
);
process.exit(1);
});

// get res
const res = (await this.send(tx, nonce, this.signed).catch(
(err: any) => {
console.log(`====> Error: ${this.id} failed: ${err}`);
errors.push(`====> Error: ${this.id} failed: ${err}`);

// FIX ME:
//
// for test now
process.exit(1);
}
)) as TxResult;

Expand All @@ -325,11 +323,6 @@ export class Extrinsic {
await this.verify(this.shared).catch((err: any) => {
console.log(`====> Error: ${this.id} verify failed: ${err}`);
errors.push(`====> Error: ${this.id} verify failed: ${err}`);

// FIX ME:
//
// for test now
process.exit(1);
});
}

Expand Down
34 changes: 15 additions & 19 deletions js/e2e/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ export default class Runner implements Config {
console.log("bootstrap e2e tests...");
console.log("establishing ws connections... (around 2 mins)");
const ps = await launch("pipe");
let runner: Runner | undefined = undefined;
if (ps.stdout) {
ps.stdout.on("data", async (chunk: Buffer) => {
process.stdout.write(chunk.toString());
if (chunk.includes(LAUNCH_COMPLETE)) {
console.log("COMPLETE LAUNCH!");
const runner = await Runner.build(exs, ws, uri);
runner = await Runner.build(exs, ws, uri);
await runner.runTxs();
}
});
Expand All @@ -84,6 +85,12 @@ export default class Runner implements Config {

// Kill all processes when exiting.
process.on("exit", () => {
if (runner && runner.errors.length > 0) {
console.log(`Failed tests: ${runner.errors.length}`);
for (const error of runner.errors) {
console.log(error);
}
}
console.log("-> exit polkadot-launch...");
killAll(ps, Number(process.exitCode));
});
Expand Down Expand Up @@ -132,13 +139,12 @@ export default class Runner implements Config {
BalanceLock: "OrmlBalanceLock",
},
},
types: Object.assign(
{
...ChainlinkTypes,
...OrmlTypes,
},
(definitions.types as any)[0].types
),
types: {
AmountOf: "Amount",
...ChainlinkTypes,
...OrmlTypes,
...(definitions.types as any)[0].types,
},
});

// new Runner
Expand Down Expand Up @@ -172,10 +178,6 @@ export default class Runner implements Config {
}

if (this.errors.length > 0) {
console.log(`Failed tests: ${this.errors.length}`);
for (const error of this.errors) {
console.log(error);
}
process.exit(1);
}
console.log("COMPLETE TESTS!");
Expand Down Expand Up @@ -252,13 +254,7 @@ export default class Runner implements Config {
})
.map((e) => {
if (e.proposal) {
return e.propose(
this.proposals,
this.finished,
this.errors,
this.exs,
this.config
);
return e.propose(this.proposals, this.exs, this.config);
} else {
let n = -1;
if (
Expand Down
11 changes: 11 additions & 0 deletions pallets/asset-index/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ benchmarks! {
add_asset {
let asset_id :T::AssetId = T::try_convert(2u8).unwrap();
let origin = T::AdminOrigin::successful_origin();
let origin_account_id = T::AdminOrigin::ensure_origin(origin.clone())?;
let million = 1_000_000u32.into();
let location = MultiLocation::Null;

Expand All @@ -37,6 +38,9 @@ benchmarks! {
AssetAvailability::Liquid(MultiLocation::Null)
)
);

T::Currency::deposit(asset_id, &origin_account_id, million)?;

let call = Call::<T>::add_asset(
asset_id,
million,
Expand Down Expand Up @@ -68,6 +72,8 @@ benchmarks! {
asset_id,
AssetAvailability::Liquid(MultiLocation::Null)
));

T::Currency::deposit(asset_id, &origin_account_id, tokens)?;
assert_ok!(AssetIndex::<T>::add_asset(
origin.clone(),
asset_id,
Expand Down Expand Up @@ -111,6 +117,8 @@ benchmarks! {
asset_id,
AssetAvailability::Liquid(MultiLocation::Null)
));

T::Currency::deposit(asset_id, &origin_account_id, admin_deposit.into())?;
assert_ok!(AssetIndex::<T>::add_asset(
origin.clone(),
asset_id,
Expand Down Expand Up @@ -228,6 +236,7 @@ benchmarks! {
asset_id,
AssetAvailability::Liquid(MultiLocation::Null)
));
T::Currency::deposit(asset_id, &origin_account_id, deposit_units)?;
assert_ok!(AssetIndex::<T>::add_asset(
origin.clone(),
asset_id,
Expand Down Expand Up @@ -269,6 +278,8 @@ benchmarks! {
asset_id,
AssetAvailability::Liquid(MultiLocation::Null)
));

T::Currency::deposit(asset_id, &origin_account_id, amount)?;
assert_ok!(AssetIndex::<T>::add_asset(origin.clone(), asset_id, units, amount));
assert_ok!(T::Currency::deposit(asset_id, &origin_account_id, units));
assert_ok!(AssetIndex::<T>::deposit(origin.clone(), asset_id, units));
Expand Down
13 changes: 8 additions & 5 deletions pallets/asset-index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,9 @@ pub mod pallet {
/// The amount of PINT minted and awarded to the LP is specified as part
/// of the associated proposal
/// Caller's balance is updated to allocate the correct amount of the
/// IndexToken. If the asset does not exist yet, it will get
/// created with the given location.
/// IndexToken.
/// The given amount of assets must already exist in the caller's account,
/// they are then transferred to the treasury account.
///
/// The Governance committee decides the tokens that comprise the index,
/// as well as the allocation of each and their value.
Expand Down Expand Up @@ -1034,8 +1035,8 @@ pub mod pallet {
}
// native asset can't be added
Self::ensure_not_native_asset(&asset_id)?;
// mint asset into the treasury account
T::Currency::deposit(asset_id, &Self::treasury_account(), units)?;
// transfer the asset from the caller to treasury account
T::Currency::transfer(asset_id, caller, &Self::treasury_account(), units)?;
// mint PINT into caller's balance increasing the total issuance
T::IndexToken::deposit_creating(caller, nav);
Ok(())
Expand Down Expand Up @@ -1140,8 +1141,10 @@ pub mod pallet {
amount: T::Balance,
) -> DispatchResult {
let origin = T::AdminOrigin::successful_origin();
let origin_account_id = T::AdminOrigin::ensure_origin(origin.clone())?;
let origin_account_id = T::AdminOrigin::ensure_origin(origin)?;

// also mint the funds
T::Currency::deposit(asset_id, &origin_account_id, amount)?;
T::PriceFeedBenchmarks::create_feed(origin_account_id, asset_id).map_err(|e| e.error)?;

// the tests of benchmarks register assets by default
Expand Down
2 changes: 2 additions & 0 deletions pallets/remote-asset-manager/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ fn can_transact_staking() {

Para::execute_with(|| {
register_relay();
// mint some funds first to cover the transfer
assert_ok!(para::Currency::deposit(RELAY_CHAIN_ASSET, &ADMIN_ACCOUNT, 1_000_000));

// fails to bond extra, no initial bond
assert_noop!(
Expand Down
5 changes: 4 additions & 1 deletion pallets/saft-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use frame_support::{
PalletId,
};
use frame_system as system;
use orml_traits::parameter_type_with_key;
use orml_traits::{parameter_type_with_key, MultiCurrency};
use pallet_price_feed::{AssetPricePair, Price, PriceFeed};
use xcm::v0::MultiLocation;

Expand Down Expand Up @@ -234,6 +234,9 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
LIQUID_ASSET_ID,
AssetAvailability::Liquid(MultiLocation::Null)
));
// mint initial supply first into admin's account
assert_ok!(Currency::deposit(LIQUID_ASSET_ID, &ADMIN_ACCOUNT_ID, initial_liquid_supply));

assert_ok!(AssetIndex::add_asset(
Origin::signed(ADMIN_ACCOUNT_ID),
LIQUID_ASSET_ID,
Expand Down