Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ledger/common/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func (n *NativeScript) UnmarshalCBOR(data []byte) error {
if _, err := cbor.Decode(data, tmpData); err != nil {
return err
}
n.item = tmpData
return nil
}

Expand Down
13 changes: 13 additions & 0 deletions ledger/common/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ func TestScriptRefDecode(t *testing.T) {
}
}

func TestNativeScriptHash(t *testing.T) {
testScriptBytes, _ := hex.DecodeString("820181830301838200581c058a5ab0c66647dcce82d7244f80bfea41ba76c7c9ccaf86a41b00fe8200581c45cbc234959cb619ef54e36c16e7719318592e627cdf1a39bd3d64398200581c85fd53e110449649b709ef0fa93e86d99535bdce5db306ce0e7418fc")
expectedScriptHash := "1c0053ec18e2c0f7bd4d007fe14243ca220563f9c124381f75c43704"
var testScript common.NativeScript
if err := testScript.UnmarshalCBOR(testScriptBytes); err != nil {
t.Fatalf("unexpected error decoding native script: %s", err)
}
tmpHash := testScript.Hash()
if tmpHash.String() != expectedScriptHash {
t.Errorf("did not get expected script hash, got %s, wanted %s", tmpHash.String(), expectedScriptHash)
}
}

func TestPlutusV3ScriptHash(t *testing.T) {
testScriptBytes, _ := hex.DecodeString("587f01010032323232323225333002323232323253330073370e900118041baa0011323232533300a3370e900018059baa00513232533300f301100214a22c6eb8c03c004c030dd50028b18069807001180600098049baa00116300a300b0023009001300900230070013004375400229309b2b2b9a5573aaae7955cfaba157441")
testScript := common.PlutusV3Script(testScriptBytes)
Expand Down