Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
test: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Oct 29, 2023
1 parent 4532acb commit 194cf2b
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 4 deletions.
53 changes: 53 additions & 0 deletions prover/proof_producer/dummty_producer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package producer

import (
"context"
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"
"github.com/taikoxyz/taiko-client/bindings"
)

func TestDummyProducerRequestProof(t *testing.T) {
producer := &DummyProofProducer{}

resCh := make(chan *ProofWithHeader, 1)

var tier uint16 = 1024

blockID := common.Big32
header := &types.Header{
ParentHash: randHash(),
UncleHash: randHash(),
Coinbase: common.BytesToAddress(randHash().Bytes()),
Root: randHash(),
TxHash: randHash(),
ReceiptHash: randHash(),
Difficulty: common.Big0,
Number: common.Big256,
GasLimit: 1024,
GasUsed: 1024,
Time: uint64(time.Now().Unix()),
Extra: randHash().Bytes(),
MixDigest: randHash(),
Nonce: types.BlockNonce{},
}
require.Nil(t, producer.RequestProof(
context.Background(),
&ProofRequestOptions{},
blockID,
&bindings.TaikoDataBlockMetadata{},
header,
tier,
resCh,
))

res := <-resCh
require.Equal(t, res.BlockID, blockID)
require.Equal(t, res.Header, header)
require.Equal(t, tier, res.Tier)
require.NotEmpty(t, res.Proof)
}
51 changes: 51 additions & 0 deletions prover/proof_producer/guardian_producer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package producer

import (
"context"
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"
"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
)

func TestGuardianProducerRequestProof(t *testing.T) {
producer := &GuardianProofProducer{}

resCh := make(chan *ProofWithHeader, 1)

blockID := common.Big32
header := &types.Header{
ParentHash: randHash(),
UncleHash: randHash(),
Coinbase: common.BytesToAddress(randHash().Bytes()),
Root: randHash(),
TxHash: randHash(),
ReceiptHash: randHash(),
Difficulty: common.Big0,
Number: common.Big256,
GasLimit: 1024,
GasUsed: 1024,
Time: uint64(time.Now().Unix()),
Extra: randHash().Bytes(),
MixDigest: randHash(),
Nonce: types.BlockNonce{},
}
require.Nil(t, producer.RequestProof(
context.Background(),
&ProofRequestOptions{},
blockID,
&bindings.TaikoDataBlockMetadata{},
header,
resCh,
))

res := <-resCh
require.Equal(t, res.BlockID, blockID)
require.Equal(t, res.Header, header)
require.Equal(t, res.Tier, encoding.TierGuardianID)
require.NotEmpty(t, res.Proof)
}
10 changes: 6 additions & 4 deletions prover/proof_producer/optimistic_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
)

func TestRequestProof(t *testing.T) {
optimisticProofProducer := &OptimisticProofProducer{}
func TestOptimisticRequestProof(t *testing.T) {
producer := &OptimisticProofProducer{}

resCh := make(chan *ProofWithHeader, 1)

blockID := common.Big32
header := &types.Header{
ParentHash: randHash(),
UncleHash: randHash(),
Coinbase: common.HexToAddress("0x0000777735367b36bC9B61C50022d9D0700dB4Ec"),
Coinbase: common.BytesToAddress(randHash().Bytes()),
Root: randHash(),
TxHash: randHash(),
ReceiptHash: randHash(),
Expand All @@ -35,7 +36,7 @@ func TestRequestProof(t *testing.T) {
MixDigest: randHash(),
Nonce: types.BlockNonce{},
}
require.Nil(t, optimisticProofProducer.RequestProof(
require.Nil(t, producer.RequestProof(
context.Background(),
&ProofRequestOptions{},
blockID,
Expand All @@ -47,6 +48,7 @@ func TestRequestProof(t *testing.T) {
res := <-resCh
require.Equal(t, res.BlockID, blockID)
require.Equal(t, res.Header, header)
require.Equal(t, res.Tier, encoding.TierOptimisticID)
require.NotEmpty(t, res.Proof)
}

Expand Down
51 changes: 51 additions & 0 deletions prover/proof_producer/sgx_producer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package producer

import (
"context"
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"
"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
)

func TestSGXProducerRequestProof(t *testing.T) {
producer := &SGXProofProducer{}

resCh := make(chan *ProofWithHeader, 1)

blockID := common.Big32
header := &types.Header{
ParentHash: randHash(),
UncleHash: randHash(),
Coinbase: common.BytesToAddress(randHash().Bytes()),
Root: randHash(),
TxHash: randHash(),
ReceiptHash: randHash(),
Difficulty: common.Big0,
Number: common.Big256,
GasLimit: 1024,
GasUsed: 1024,
Time: uint64(time.Now().Unix()),
Extra: randHash().Bytes(),
MixDigest: randHash(),
Nonce: types.BlockNonce{},
}
require.Nil(t, producer.RequestProof(
context.Background(),
&ProofRequestOptions{},
blockID,
&bindings.TaikoDataBlockMetadata{},
header,
resCh,
))

res := <-resCh
require.Equal(t, res.BlockID, blockID)
require.Equal(t, res.Header, header)
require.Equal(t, res.Tier, encoding.TierSgxID)
require.NotEmpty(t, res.Proof)
}
3 changes: 3 additions & 0 deletions prover/proof_producer/zkevm_rpcd_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestNewZkevmRpcdProducer(t *testing.T) {
&bindings.TaikoDataConfig{},
)
require.Nil(t, err)
require.False(t, dummyZkevmRpcdProducer.Cancellable())

dummyZkevmRpcdProducer.CustomProofHook = func() ([]byte, uint64, error) {
return []byte{0}, CircuitsIdx, nil
Expand Down Expand Up @@ -59,4 +60,6 @@ func TestNewZkevmRpcdProducer(t *testing.T) {
require.Equal(t, res.BlockID, blockID)
require.Equal(t, res.Header, header)
require.NotEmpty(t, res.Proof)

require.Nil(t, dummyZkevmRpcdProducer.Cancel(context.Background(), common.Big1))
}

0 comments on commit 194cf2b

Please sign in to comment.