|
| 1 | +import { test, expect } from '@playwright/test' |
| 2 | +import { E2EWindow } from '../../src/app/pages/E2EPage/E2EWindow' |
| 3 | + |
| 4 | +for (const net of ['mainnet', 'testnet']) { |
| 5 | + test(`Check if hardcoded consensus fee needs to be updated (setFeeAmount(oasis.quantity.fromBigInt(0n))) : ${net}`, async ({ |
| 6 | + page, |
| 7 | + }) => { |
| 8 | + await page.goto('/e2e') |
| 9 | + |
| 10 | + const estimatedGas = await page.evaluate( |
| 11 | + async ([net]) => { |
| 12 | + const { oasis, grpcWeb } = window as E2EWindow |
| 13 | + |
| 14 | + const nic = |
| 15 | + net === 'mainnet' |
| 16 | + ? new oasis.client.NodeInternal('https://grpc.oasis.io') |
| 17 | + : new oasis.client.NodeInternal('https://testnet.grpc.oasis.io') |
| 18 | + |
| 19 | + function toCBOR(v) { |
| 20 | + // gRPC cannot handle nil arguments unmarshalled from CBOR, so we use a special case to |
| 21 | + // marshal `nil` to an empty byte string. |
| 22 | + if (v == null) return new Uint8Array() |
| 23 | + return oasis.misc.toCBOR(v) |
| 24 | + } |
| 25 | + function createMethodDescriptorUnary(serviceName, methodName) { |
| 26 | + const MethodType = grpcWeb.MethodType |
| 27 | + return new grpcWeb.MethodDescriptor( |
| 28 | + `/oasis-core.${serviceName}/${methodName}`, |
| 29 | + MethodType.UNARY, |
| 30 | + null as any, |
| 31 | + null as any, |
| 32 | + toCBOR, |
| 33 | + oasis.misc.fromCBOR, |
| 34 | + ) |
| 35 | + } |
| 36 | + const methodDescriptorConsensusMinGasPrice = createMethodDescriptorUnary('Consensus', 'MinGasPrice') |
| 37 | + |
| 38 | + // `const minPrice = await nic.consensusMinGasPrice()` in next version |
| 39 | + const minPrice = await nic['callUnary']<undefined, Uint8Array>( |
| 40 | + methodDescriptorConsensusMinGasPrice, |
| 41 | + undefined, |
| 42 | + ) |
| 43 | + return oasis.quantity.toBigInt(minPrice).toString() |
| 44 | + }, |
| 45 | + [net] as const, |
| 46 | + ) |
| 47 | + |
| 48 | + expect(estimatedGas).toBe('0') |
| 49 | + }) |
| 50 | +} |
0 commit comments