package qrc import "testing" // The tests below tell what one call to Verify costs in gas. Run // // gno test -v -run TestGas ./qrc // // and, for each hash function, subtract the gas of the Setup test from the // gas of the Verify test, then divide by gasRuns. The figure covers the // virtual machine alone: a transaction also pays for its size and for what // it stores. const ( gasRuns = 10 gasHeight = MinHeight gasLeaf = 37 ) var gasMessage = []byte("bind this key to my account") func gasVerify(t *testing.T, h Hash, runs int) { root, proof := testProof(h, gasHeight, gasLeaf, gasMessage) for i := 0; i < runs; i++ { if err := Verify(h, root, gasHeight, gasLeaf, gasMessage, proof); err != nil { t.Fatalf("%s: %v", h, err) } } } func TestGasSetupSHA256(t *testing.T) { gasVerify(t, SHA256, 0) } func TestGasVerifySHA256(t *testing.T) { gasVerify(t, SHA256, gasRuns) } func TestGasSetupKeccak256(t *testing.T) { gasVerify(t, Keccak256, 0) } func TestGasVerifyKeccak256(t *testing.T) { gasVerify(t, Keccak256, gasRuns) }