github.com/cryptotooltop/go-ethereum@v0.0.0-20231103184714-151d1922f3e5/core/rawdb/accessors_row_consumption_test.go (about)

     1  package rawdb
     2  
     3  import (
     4  	"math/big"
     5  	"reflect"
     6  	"testing"
     7  
     8  	"github.com/scroll-tech/go-ethereum/common"
     9  	"github.com/scroll-tech/go-ethereum/core/types"
    10  )
    11  
    12  func TestReadBlockRowConsumption(t *testing.T) {
    13  	l2BlockHash := common.BigToHash(big.NewInt(10))
    14  	rc := types.RowConsumption{
    15  		types.SubCircuitRowUsage{Name: "aa", RowNumber: 12},
    16  		types.SubCircuitRowUsage{Name: "bb", RowNumber: 100},
    17  	}
    18  	db := NewMemoryDatabase()
    19  	WriteBlockRowConsumption(db, l2BlockHash, &rc)
    20  	got := ReadBlockRowConsumption(db, l2BlockHash)
    21  	if got == nil || !reflect.DeepEqual(rc, *got) {
    22  		t.Fatal("RowConsumption mismatch", "expected", rc, "got", got)
    23  	}
    24  }