-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test on receipt with new version #100
- Loading branch information
Showing
4 changed files
with
94 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { testEnv } from "../../test/testEnv.js"; | ||
import { Faucet, WalletV1 } from "../contracts/index.js"; | ||
import { | ||
HttpTransport, | ||
PublicClient, | ||
convertEthToWei, | ||
waitTillCompleted, | ||
} from "../index.js"; | ||
import { LocalECDSAKeySigner } from "../signers/LocalECDSAKeySigner.js"; | ||
import { generateRandomPrivateKey } from "../signers/privateKey.js"; | ||
|
||
const client = new PublicClient({ | ||
transport: new HttpTransport({ | ||
endpoint: testEnv.endpoint, | ||
}), | ||
shardId: 1, | ||
}); | ||
|
||
test("Receipt test", async ({ expect }) => { | ||
const faucet = new Faucet(client); | ||
|
||
const signer = new LocalECDSAKeySigner({ | ||
privateKey: generateRandomPrivateKey(), | ||
}); | ||
|
||
const pubkey = await signer.getPublicKey(); | ||
|
||
const wallet = new WalletV1({ | ||
pubkey: pubkey, | ||
salt: 100n, | ||
shardId: 1, | ||
client, | ||
signer, | ||
}); | ||
const walletAddress = await wallet.getAddressHex(); | ||
|
||
expect(walletAddress).toBeDefined(); | ||
|
||
const faucetHash = await faucet.withdrawToWithRetry( | ||
walletAddress, | ||
convertEthToWei(0.1), | ||
); | ||
|
||
const receipts = await waitTillCompleted(client, 1, faucetHash); | ||
|
||
expect(receipts).toBeDefined(); | ||
for (const receipt of receipts) { | ||
expect(receipt).toBeDefined(); | ||
expect(receipt.gasPrice).toBeDefined(); | ||
expect(receipt.gasUsed).toBeDefined(); | ||
expect(receipt.gasPrice).toBeTypeOf("bigint"); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters