MCPcopy Create free account
hub / github.com/chain/txvm / TestVMHash

Function TestVMHash

protocol/txvm/crypto_test.go:10–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestVMHash(t *testing.T) {
11 cases := []struct {
12 fn string
13 inp []byte
14 wantHex string
15 }{
16 {"f", []byte("x"), "17d00cf13f5cb7024201fadb919b1778804923fc01818cf2f1b904f7bf563d1f"},
17 {"function_name", []byte("x_input"), "e7830b396576c7c0c33aab33ca084756f1c3a0cf0d413298a716d0378eb6f114"},
18 }
19
20 for i, c := range cases {
21 t.Run(fmt.Sprintf("case %d", i), func(t *testing.T) {
22 got := VMHash(c.fn, c.inp)
23 want, _ := hex.DecodeString(c.wantHex)
24 if !bytes.Equal(got[:], want) {
25 t.Errorf("got %x, want %x", got[:], want)
26 }
27 })
28 }
29}

Callers

nothing calls this directly

Calls 2

VMHashFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected