-
Notifications
You must be signed in to change notification settings - Fork 0
/
circuit_test.go
65 lines (55 loc) · 1.54 KB
/
circuit_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package age
import (
"context"
"math/big"
"testing"
"github.com/brevis-network/brevis-sdk/sdk"
"github.com/brevis-network/brevis-sdk/test"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
)
func TestCircuit(t *testing.T) {
app, err := sdk.NewBrevisApp()
check(err)
ec, err := ethclient.Dial("https://eth.llamarpc.com")
check(err)
txHash := common.HexToHash(
"4a18c7762036fcd4016d9ba74b40a8c3614adf9b6f7c6439c4675f9e828211c8")
tx, _, err := ec.TransactionByHash(context.Background(), txHash)
check(err)
receipt, err := ec.TransactionReceipt(context.Background(), txHash)
check(err)
from, err := types.Sender(types.NewLondonSigner(tx.ChainId()), tx)
check(err)
gtc := big.NewInt(0)
gasFeeCap := big.NewInt(0)
if tx.Type() == types.LegacyTxType {
gtc = tx.GasPrice()
} else {
gtc = tx.GasTipCap()
gasFeeCap = tx.GasFeeCap()
}
app.AddTransaction(sdk.TransactionData{
Hash: txHash,
ChainId: tx.ChainId(),
BlockNum: receipt.BlockNumber,
Nonce: tx.Nonce(),
GasTipCapOrGasPrice: gtc,
GasFeeCap: gasFeeCap,
GasLimit: tx.Gas(),
From: from,
To: *tx.To(),
Value: tx.Value(),
})
guest := &AppCircuit{}
guestAssignment := &AppCircuit{}
circuitInput, err := app.BuildCircuitInput(guest)
check(err)
test.ProverSucceeded(t, guest, guestAssignment, circuitInput)
}
func check(err error) {
if err != nil {
panic(err)
}
}