Merge branch 'staging' into VDB-101-vat-fold-transformer

Conflicts:
	cmd/continuousLogSync.go
	db/schema.sql
	pkg/transformers/shared/constants.go
	pkg/transformers/transformers.go
	test_config/test_config.go
This commit is contained in:
David Terry
2018-10-10 14:09:14 +03:00
52 changed files with 2760 additions and 17 deletions
+6
View File
@@ -55,8 +55,11 @@ var (
pitFileIlkMethod = "file(bytes32,bytes32,uint256)"
pitFileStabilityFeeMethod = GetSolidityMethodSignature(PitABI, "file")
tendMethod = GetSolidityMethodSignature(FlipperABI, "tend")
vatGrabMethod = GetSolidityMethodSignature(VatABI, "grab")
vatInitMethod = GetSolidityMethodSignature(VatABI, "init")
vatFoldMethod = GetSolidityMethodSignature(VatABI, "fold")
vatTollMethod = GetSolidityMethodSignature(VatABI, "toll")
vatTuneMethod = GetSolidityMethodSignature(VatABI, "tune")
BiteSignature = GetEventSignature(biteMethod)
DealSignature = GetLogNoteSignature(dealMethod)
@@ -76,6 +79,9 @@ var (
PitFileIlkSignature = GetLogNoteSignature(pitFileIlkMethod)
PitFileStabilityFeeSignature = GetLogNoteSignature(pitFileStabilityFeeMethod)
TendFunctionSignature = GetLogNoteSignature(tendMethod)
VatGrabSignature = GetLogNoteSignature(vatGrabMethod)
VatInitSignature = GetLogNoteSignature(vatInitMethod)
VatFoldSignature = GetLogNoteSignature(vatFoldMethod)
VatTollSignature = GetLogNoteSignature(vatTollMethod)
VatTuneSignature = GetLogNoteSignature(vatTuneMethod)
)
@@ -132,6 +132,13 @@ var _ = Describe("Event signature generator", func() {
Expect(expected).To(Equal(actual))
})
It("gets the vat grab method signature", func() {
expected := "grab(bytes32,bytes32,bytes32,bytes32,int256,int256)"
actual := shared.GetSolidityMethodSignature(shared.VatABI, "grab")
Expect(expected).To(Equal(actual))
})
})
Describe("it handles events", func() {
+12
View File
@@ -32,3 +32,15 @@ func BigIntToString(value *big.Int) string {
return result
}
}
func GetDataBytesAtIndex(n int, logData []byte) []byte {
switch {
case n == -1:
return logData[len(logData)-DataItemLength:]
case n == -2:
return logData[len(logData)-(2*DataItemLength) : len(logData)-DataItemLength]
case n == -3:
return logData[len(logData)-(3*DataItemLength) : len(logData)-(2*DataItemLength)]
}
return []byte{}
}
+49
View File
@@ -0,0 +1,49 @@
package shared_test
import (
"github.com/ethereum/go-ethereum/common/hexutil"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/ethereum/go-ethereum/common"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"math/big"
)
var _ = Describe("Shared utilities", func() {
Describe("getting data at index", func() {
It("gets bytes for the last index in log data", func() {
logData := hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c45dd6471a66616b6520696c6b0000000000000000000000000000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b00000000000000000000000000f243e26db94b5426032e6dfa6007802dea2a61400000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15000000000000000000000000000000000000000000000000000000003ade68b1")
bigIntBytes := big.NewInt(987654321).Bytes()
// big.Int.Bytes() does not include zero padding, but bytes in data index are of fixed length and include zero padding
expected := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
expected = append(expected, bigIntBytes...)
actual := shared.GetDataBytesAtIndex(-1, logData)
Expect(expected[:]).To(Equal(actual))
})
It("gets bytes for the second-to-last index in log data", func() {
logData := hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c45dd6471a66616b6520696c6b0000000000000000000000000000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b00000000000000000000000000f243e26db94b5426032e6dfa6007802dea2a61400000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15000000000000000000000000000000000000000000000000000000003ade68b1")
bigIntBytes := big.NewInt(123456789).Bytes()
expected := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
expected = append(expected, bigIntBytes...)
actual := shared.GetDataBytesAtIndex(-2, logData)
Expect(expected[:]).To(Equal(actual))
})
It("gets bytes for the third-to-last index in log data", func() {
logData := hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c45dd6471a66616b6520696c6b0000000000000000000000000000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b00000000000000000000000000f243e26db94b5426032e6dfa6007802dea2a61400000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15000000000000000000000000000000000000000000000000000000003ade68b1")
addressBytes := common.HexToAddress("0x0F243E26db94B5426032E6DFA6007802Dea2a614").Bytes()
// common.address.Bytes() returns [20]byte{}, need [32]byte{}
expected := append(addressBytes, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}...)
actual := shared.GetDataBytesAtIndex(-3, logData)
Expect(expected[:]).To(Equal(actual))
})
})
})