mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-04-01 03:46:40 +00:00
* deleted transfer_output added asset type and transaction result to core * removed writing 0x00 when buffer length is 0 * Refactored emit into VM package + moved tx to own package. * implemented transaction along with claimTransaction. * refactored naming of transaction + added decode address for uint160 types * removed unnecessary folder and files. * transaction/smartcontract logic * bumped version 0.24.0
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package payload
|
|
|
|
import (
|
|
"bytes"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/core"
|
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
|
)
|
|
|
|
func TestHeadersEncodeDecode(t *testing.T) {
|
|
headers := &Headers{[]*core.Header{
|
|
&core.Header{
|
|
BlockBase: core.BlockBase{
|
|
Version: 0,
|
|
Index: 1,
|
|
Script: &transaction.Witness{
|
|
InvocationScript: []byte{0x0},
|
|
VerificationScript: []byte{0x1},
|
|
},
|
|
}},
|
|
&core.Header{
|
|
BlockBase: core.BlockBase{
|
|
Version: 0,
|
|
Index: 2,
|
|
Script: &transaction.Witness{
|
|
InvocationScript: []byte{0x0},
|
|
VerificationScript: []byte{0x1},
|
|
},
|
|
}},
|
|
&core.Header{
|
|
BlockBase: core.BlockBase{
|
|
Version: 0,
|
|
Index: 3,
|
|
Script: &transaction.Witness{
|
|
InvocationScript: []byte{0x0},
|
|
VerificationScript: []byte{0x1},
|
|
},
|
|
}},
|
|
}}
|
|
|
|
buf := new(bytes.Buffer)
|
|
if err := headers.EncodeBinary(buf); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
headersDecode := &Headers{}
|
|
if err := headersDecode.DecodeBinary(buf); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !reflect.DeepEqual(headers, headersDecode) {
|
|
t.Fatalf("expected both header payload to be equal %+v and %+v", headers, headersDecode)
|
|
}
|
|
}
|