git.delta.rocks / unique-network / refs/commits / 408e6a1db82d

difftreelog

Add requireAwait rule to avoid flakiness in tests

Max Andreev2022-10-25parent: #bb1e6df.patch.diff
in: master

2 files changed

modifiedtests/.eslintrc.jsondiffbeforeafterboth
--- a/tests/.eslintrc.json
+++ b/tests/.eslintrc.json
@@ -42,6 +42,7 @@
                 "avoidEscape": true
             }
         ],
+        "require-await": 2,
         "semi": [
             "error",
             "always"
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
1627 * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})1627 * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})
1628 * @returns ```true``` if extrinsic success, otherwise ```false```1628 * @returns ```true``` if extrinsic success, otherwise ```false```
1629 */1629 */
1630 async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId) {1630 approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId) {
1631 return super.approveToken(signer, collectionId, tokenId, toAddressObj, 1n);1631 return super.approveToken(signer, collectionId, tokenId, toAddressObj, 1n);
1632 }1632 }
1633}1633}
1820 * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5GHoZe9c73RYbVzq..."}, "", 10000n);1820 * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5GHoZe9c73RYbVzq..."}, "", 10000n);
1821 * @returns true if the token success, otherwise false1821 * @returns true if the token success, otherwise false
1822 */1822 */
1823 async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, amount=1n) {1823 approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, amount=1n) {
1824 return super.approveToken(signer, collectionId, tokenId, toAddressObj, amount);1824 return super.approveToken(signer, collectionId, tokenId, toAddressObj, amount);
1825 }1825 }
18261826
2032 * @example approveTokens(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n)2032 * @example approveTokens(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n)
2033 * @returns ```true``` if extrinsic success, otherwise ```false```2033 * @returns ```true``` if extrinsic success, otherwise ```false```
2034 */2034 */
2035 async approveTokens(signer: IKeyringPair, collectionId: number, toAddressObj: ICrossAccountId, amount=1n) {2035 approveTokens(signer: IKeyringPair, collectionId: number, toAddressObj: ICrossAccountId, amount=1n) {
2036 return super.approveToken(signer, collectionId, 0, toAddressObj, amount);2036 return super.approveToken(signer, collectionId, 0, toAddressObj, amount);
2037 }2037 }
20382038
2043 * @param toAddressObj the address approved for the transfer of tokens on behalf of the owner2043 * @param toAddressObj the address approved for the transfer of tokens on behalf of the owner
2044 * @returns number of tokens approved for the transfer2044 * @returns number of tokens approved for the transfer
2045 */2045 */
2046 async getApprovedTokens(collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId) {2046 getApprovedTokens(collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId) {
2047 return super.getTokenApprovedPieces(collectionId, 0, toAddressObj, fromAddressObj);2047 return super.getTokenApprovedPieces(collectionId, 0, toAddressObj, fromAddressObj);
2048 }2048 }
2049}2049}
2220 * @example getSubstrate("5GrwvaEF5zXb26Fz...")2220 * @example getSubstrate("5GrwvaEF5zXb26Fz...")
2221 * @returns amount of tokens on address2221 * @returns amount of tokens on address
2222 */2222 */
2223 async getSubstrate(address: TSubstrateAccount): Promise<bigint> {2223 getSubstrate(address: TSubstrateAccount): Promise<bigint> {
2224 return this.subBalanceGroup.getSubstrate(address);2224 return this.subBalanceGroup.getSubstrate(address);
2225 }2225 }
22262226
2229 * @param address substrate address2229 * @param address substrate address
2230 * @returns2230 * @returns
2231 */2231 */
2232 async getSubstrateFull(address: TSubstrateAccount): Promise<ISubstrateBalance> {2232 getSubstrateFull(address: TSubstrateAccount): Promise<ISubstrateBalance> {
2233 return this.subBalanceGroup.getSubstrateFull(address);2233 return this.subBalanceGroup.getSubstrateFull(address);
2234 }2234 }
22352235
2239 * @example getEthereum("0x9F0583DbB855d...")2239 * @example getEthereum("0x9F0583DbB855d...")
2240 * @returns amount of tokens on address2240 * @returns amount of tokens on address
2241 */2241 */
2242 async getEthereum(address: TEthereumAccount): Promise<bigint> {2242 getEthereum(address: TEthereumAccount): Promise<bigint> {
2243 return this.ethBalanceGroup.getEthereum(address);2243 return this.ethBalanceGroup.getEthereum(address);
2244 }2244 }
22452245
2251 * @example transferToSubstrate(aliceKeyring, "5GrwvaEF5zXb26Fz...", 100_000_000_000n);2251 * @example transferToSubstrate(aliceKeyring, "5GrwvaEF5zXb26Fz...", 100_000_000_000n);
2252 * @returns ```true``` if extrinsic success, otherwise ```false```2252 * @returns ```true``` if extrinsic success, otherwise ```false```
2253 */2253 */
2254 async transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {2254 transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {
2255 return this.subBalanceGroup.transferToSubstrate(signer, address, amount);2255 return this.subBalanceGroup.transferToSubstrate(signer, address, amount);
2256 }2256 }
2257}2257}
2402 super(helper);2402 super(helper);
2403 }2403 }
24042404
2405 async cancelScheduled(signer: TSigner, scheduledId: string) {2405 cancelScheduled(signer: TSigner, scheduledId: string) {
2406 return this.helper.executeExtrinsic(2406 return this.helper.executeExtrinsic(
2407 signer,2407 signer,
2408 'api.tx.scheduler.cancelNamed',2408 'api.tx.scheduler.cancelNamed',
2411 );2411 );
2412 }2412 }
24132413
2414 async changePriority(signer: TSigner, scheduledId: string, priority: number) {2414 changePriority(signer: TSigner, scheduledId: string, priority: number) {
2415 return this.helper.executeExtrinsic(2415 return this.helper.executeExtrinsic(
2416 signer,2416 signer,
2417 'api.tx.scheduler.changeNamedPriority',2417 'api.tx.scheduler.changeNamedPriority',