MCPcopy Create free account
hub / github.com/DNAProject/DNA / simplifyNeoBytes

Function simplifyNeoBytes

common/bigint_test.go:131–150  ·  view source on GitHub ↗
(buf []byte)

Source from the content-addressed store, hash-verified

129}
130
131func simplifyNeoBytes(buf []byte) []byte {
132 if len(buf) <= 1 {
133 if bytes.Equal(buf, []byte{0}) {
134 return nil
135 }
136 return buf
137 }
138 i := len(buf)
139 if buf[i-1] == 255 {
140 return trimFF(buf)
141 } else if buf[i-1] == 0 {
142 buf = trim00(buf)
143 // treat bytes(0) to nil
144 if bytes.Equal(buf, []byte{0}) {
145 return nil
146 }
147 return buf
148 }
149 return buf
150}
151
152func TestSimplifyNeoBytes(t *testing.T) {
153 assert.Equal(t, simplifyNeoBytes([]byte{255}), []byte{255})

Callers 3

TestBigIntFromBytesFunction · 0.85
TestRandBigIntFromBytesFunction · 0.85
TestSimplifyNeoBytesFunction · 0.85

Calls 2

trimFFFunction · 0.85
trim00Function · 0.85

Tested by

no test coverage detected