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

Function TestWitnessHash

protocol/bc/tx_test.go:209–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func TestWitnessHash(t *testing.T) {
210 raw, err := asm.Assemble(`"blockchainidblockchainidblockcha" 1000 nonce finalize`)
211 if err != nil {
212 testutil.FatalErr(t, err)
213 }
214 tx, err := NewTx(raw, 3, 1000)
215 if err != nil {
216 testutil.FatalErr(t, err)
217 }
218
219 want, _ := hex.DecodeString("039a050d18522e49736038842b0a759f7addf16e3c017d6aec5d976061062b13b0f95a7a8b977557c1f6d012207304f5e4e0349b2683090abe98c0705d8434af")
220
221 var b bytes.Buffer
222 _, err = tx.WriteWitnessCommitmentTo(&b)
223 if err != nil {
224 t.Fatal(err)
225 }
226 if !bytes.Equal(b.Bytes(), want) {
227 t.Errorf("Tx.WriteWitnessCommitmentTo yields %x, want %x", b.Bytes(), want)
228 }
229}

Callers

nothing calls this directly

Calls 6

AssembleFunction · 0.92
FatalErrFunction · 0.92
NewTxFunction · 0.85
EqualMethod · 0.80
BytesMethod · 0.45

Tested by

no test coverage detected