Skip to content

Commit

Permalink
verkle test: count the code chunks in the witness (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed May 9, 2022
1 parent 6856df3 commit 5975b44
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func TestProcessVerkleCodeDeployExec(t *testing.T) {
gen.AddTx(tx)
} else {
// Call the contract's `store` function in block #2
tx, _ := types.SignTx(types.NewTransaction(1, contractAddr, big.NewInt(16), 3000000, big.NewInt(875000000), callStoreInput), signer, testKey)
tx, _ := types.SignTx(types.NewTransaction(1, contractAddr, big.NewInt(0), 3000000, big.NewInt(875000000), callStoreInput), signer, testKey)
gen.AddTx(tx)
}
})
Expand Down Expand Up @@ -536,9 +536,11 @@ func TestProcessVerkleCodeDeployExec(t *testing.T) {
}

hascode = false
codeCount := 0
for _, kv := range b2.Header().VerkleKeyVals {
if bytes.Equal(contractStem[:], kv.Key[:31]) && kv.Key[31] >= 128 {
hascode = true
codeCount++

if len(kv.Value) == 0 {
t.Fatal("chunk value for called code should not be empty in witness")
Expand All @@ -558,4 +560,8 @@ func TestProcessVerkleCodeDeployExec(t *testing.T) {
if !hascode {
t.Fatal("could not find contract code in the witness of the calling block")
}

if codeCount != 10 {
t.Fatalf("got %d code chunks, expected 10", codeCount)
}
}

0 comments on commit 5975b44

Please sign in to comment.