Abstract TxProcessor from StateDB

- Abstract TxProcessor from StateDB
- Upgrade to last version of go-merkletree for the key-value DB usage
This commit is contained in:
arnaucube
2020-12-28 16:57:13 +01:00
parent 025b56c8c3
commit 0cf1ed217b
23 changed files with 778 additions and 777 deletions

39
txprocessor/utils_test.go Normal file
View File

@@ -0,0 +1,39 @@
package txprocessor
import (
"math/big"
"testing"
"github.com/iden3/go-iden3-crypto/babyjub"
"github.com/stretchr/testify/assert"
)
func TestBJJCompressedTo256BigInt(t *testing.T) {
var pkComp babyjub.PublicKeyComp
r := BJJCompressedTo256BigInts(pkComp)
zero := big.NewInt(0)
for i := 0; i < 256; i++ {
assert.Equal(t, zero, r[i])
}
pkComp[0] = 3
r = BJJCompressedTo256BigInts(pkComp)
one := big.NewInt(1)
for i := 0; i < 256; i++ {
if i != 0 && i != 1 {
assert.Equal(t, zero, r[i])
} else {
assert.Equal(t, one, r[i])
}
}
pkComp[31] = 4
r = BJJCompressedTo256BigInts(pkComp)
for i := 0; i < 256; i++ {
if i != 0 && i != 1 && i != 250 {
assert.Equal(t, zero, r[i])
} else {
assert.Equal(t, one, r[i])
}
}
}