neo-go/pkg/vm/tests/byte_conversion_test.go
Anthony De Meulemeester 35551282b0
Porting the NEX ICO template to neo-go as first class smart contract example (#78)
* Initial draft of the ICO template ported from NEX.

* filled in token configuration

* added kyc storage prefix

* fixed byte array conversion + added tests

* fixed broken test + made 1 file for the token sale example.

* implemented the NEP5 handlers

* bumped version
2018-05-06 08:03:26 +02:00

56 lines
850 B
Go

package vm_test
import "testing"
func TestStringToByteConversion(t *testing.T) {
src := `
package foo
func Main() []byte {
b := []byte("foo")
return b
}
`
eval(t, src, []byte("foo"))
}
func TestStringToByteAppend(t *testing.T) {
src := `
package foo
func Main() []byte {
b := []byte("foo")
c := []byte("bar")
e := append(b, c...)
return e
}
`
eval(t, src, []byte("foobar"))
}
func TestByteConversionInFunctionCall(t *testing.T) {
src := `
package foo
func Main() []byte {
b := []byte("foo")
return handle(b)
}
func handle(b []byte) []byte {
return b
}
`
eval(t, src, []byte("foo"))
}
func TestByteConversionDirectlyInFunctionCall(t *testing.T) {
src := `
package foo
func Main() []byte {
return handle([]byte("foo"))
}
func handle(b []byte) []byte {
return b
}
`
eval(t, src, []byte("foo"))
}