| 8 | ) |
| 9 | |
| 10 | func 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 | } |