(t *testing.T)
| 846 | } |
| 847 | |
| 848 | func TestScript_PushSingleData(t *testing.T) { |
| 849 | tests := []struct { |
| 850 | in []byte |
| 851 | wantScriptData []byte |
| 852 | wantError error |
| 853 | description string |
| 854 | }{ |
| 855 | {nil, []byte{0x00}, nil, "Nil data to test."}, |
| 856 | { |
| 857 | bytes.Repeat([]byte{0x00}, OP_PUSHDATA1), |
| 858 | combineBytes([]byte{0x4c, 0x4c}, bytes.Repeat([]byte{0x00}, 0x4c)), |
| 859 | nil, |
| 860 | "Push 0X4c data to test.", |
| 861 | }, |
| 862 | { |
| 863 | bytes.Repeat([]byte{0x00}, 0xff), |
| 864 | combineBytes([]byte{0x4c, 0xff}, bytes.Repeat([]byte{0x00}, 0xff)), |
| 865 | nil, |
| 866 | "Push 0xff data to test.", |
| 867 | }, |
| 868 | { |
| 869 | bytes.Repeat([]byte{0x00}, 0xffff), |
| 870 | combineBytes([]byte{0x4d, 0xff, 0xff}, bytes.Repeat([]byte{0x00}, 0xffff)), |
| 871 | nil, |
| 872 | "Push 0xffff data to test.", |
| 873 | }, |
| 874 | { |
| 875 | bytes.Repeat([]byte{0x00}, 0x010000), |
| 876 | combineBytes([]byte{0x4e, 0x00, 0x00, 0x01, 0x00}, bytes.Repeat([]byte{0x00}, 0x010000)), |
| 877 | nil, |
| 878 | "Push 0x010000 data to test.", |
| 879 | }, |
| 880 | } |
| 881 | |
| 882 | for _, v := range tests { |
| 883 | value := v |
| 884 | |
| 885 | nullScript := NewEmptyScript() |
| 886 | err := nullScript.PushSingleData(value.in) |
| 887 | assert.Equal(t, value.wantError, err, value.description) |
| 888 | data := nullScript.Bytes() |
| 889 | assert.Equal(t, hex.EncodeToString(value.wantScriptData), hex.EncodeToString(data), value.description) |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | func combineBytes(pBytes ...[]byte) []byte { |
| 894 | return bytes.Join(pBytes, []byte{}) |
nothing calls this directly
no test coverage detected