OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / protocol / vm / vmutil / script_test.go
1 package vmutil
2
3 import (
4         "testing"
5 )
6
7 // TestIsUnspendable ensures the IsUnspendable function returns the expected
8 // results.
9 func TestIsUnspendable(t *testing.T) {
10         tests := []struct {
11                 pkScript []byte
12                 expected bool
13         }{
14                 {
15                         // Unspendable
16                         pkScript: []byte{0x6a, 0x04, 0x74, 0x65, 0x73, 0x74},
17                         expected: true,
18                 },
19                 {
20                         // Spendable
21                         pkScript: []byte{0x76, 0xa9, 0x14, 0x29, 0x95, 0xa0,
22                                 0xfe, 0x68, 0x43, 0xfa, 0x9b, 0x95, 0x45,
23                                 0x97, 0xf0, 0xdc, 0xa7, 0xa4, 0x4d, 0xf6,
24                                 0xfa, 0x0b, 0x5c, 0x88, 0xac},
25                         expected: false,
26                 },
27         }
28
29         for i, test := range tests {
30                 res := IsUnspendable(test.pkScript)
31                 if res != test.expected {
32                         t.Errorf("TestIsUnspendable #%d failed: got %v want %v",
33                                 i, res, test.expected)
34                         continue
35                 }
36         }
37 }