11import * as dotenv from "dotenv"
22import { describe , it , expect , beforeAll } from "@jest/globals"
33import { JsonRpcProvider , NonceManager , Wallet , WebSocketProvider } from "ethers"
4- import { FILECOIN_CALIBNET_CONTRACT_ADDRESS , FURNACE_TESTNET_CONTRACT_ADDRESS , Randomness } from "../src"
4+ import {
5+ BASE_SEPOLIA_CONTRACT_ADDRESS ,
6+ FILECOIN_CALIBNET_CONTRACT_ADDRESS ,
7+ FURNACE_TESTNET_CONTRACT_ADDRESS ,
8+ Randomness
9+ } from "../src"
510
611// filecoin calibnet might take forever
712const TEST_TIMEOUT = 200_000
813describe ( "randomness" , ( ) => {
914 beforeAll ( ( ) => {
1015 dotenv . config ( )
1116 } )
12-
13- it ( "can be requested from filecoin testnet and verified" , async ( ) => {
17+
18+ it ( "can be requested from filecoin testnet and verified" , async ( ) => {
1419 const rpc = createProvider ( process . env . FILECOIN_RPC_URL || "" )
1520 const wallet = new NonceManager ( new Wallet ( process . env . FILECOIN_PRIVATE_KEY || "" , rpc ) )
1621
@@ -37,6 +42,20 @@ describe("randomness", () => {
3742 rpc . destroy ( )
3843 } , TEST_TIMEOUT )
3944
45+ it ( "can be requested from a base sepolia and verified" , async ( ) => {
46+ const rpc = createProvider ( process . env . BASE_RPC_URL || "" )
47+ const wallet = new NonceManager ( new Wallet ( process . env . BASE_PRIVATE_KEY || "" , rpc ) )
48+
49+ const randomness = new Randomness ( wallet , BASE_SEPOLIA_CONTRACT_ADDRESS )
50+ expect ( randomness ) . not . toEqual ( null )
51+
52+ const response = await randomness . requestRandomness ( 1 , TEST_TIMEOUT )
53+ console . log ( "randomness requested" )
54+ await randomness . verify ( response )
55+
56+ rpc . destroy ( )
57+ } , TEST_TIMEOUT )
58+
4059} )
4160
4261function createProvider ( url : string ) : JsonRpcProvider | WebSocketProvider {
0 commit comments