-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transaction: fix witness script length limits
See neo-project/neo#1958.
- Loading branch information
1 parent
273b803
commit d029f5c
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package transaction | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestWitnessSerDes(t *testing.T) { | ||
var good1 = &Witness{ | ||
InvocationScript: make([]byte, 64), | ||
VerificationScript: make([]byte, 32), | ||
} | ||
var good2 = &Witness{ | ||
InvocationScript: make([]byte, MaxInvocationScript), | ||
VerificationScript: make([]byte, MaxVerificationScript), | ||
} | ||
var bad1 = &Witness{ | ||
InvocationScript: make([]byte, MaxInvocationScript+1), | ||
VerificationScript: make([]byte, 32), | ||
} | ||
var bad2 = &Witness{ | ||
InvocationScript: make([]byte, 128), | ||
VerificationScript: make([]byte, MaxVerificationScript+1), | ||
} | ||
var exp = new(Witness) | ||
testserdes.MarshalUnmarshalJSON(t, good1, exp) | ||
testserdes.MarshalUnmarshalJSON(t, good2, exp) | ||
testserdes.EncodeDecodeBinary(t, good1, exp) | ||
testserdes.EncodeDecodeBinary(t, good2, exp) | ||
bin1, err := testserdes.EncodeBinary(bad1) | ||
require.NoError(t, err) | ||
bin2, err := testserdes.EncodeBinary(bad2) | ||
require.NoError(t, err) | ||
require.Error(t, testserdes.DecodeBinary(bin1, exp)) | ||
require.Error(t, testserdes.DecodeBinary(bin2, exp)) | ||
} |