2018-11-23 18:12:24 +00:00
|
|
|
// VulcanizeDB
|
2019-03-12 15:46:42 +00:00
|
|
|
// Copyright © 2019 Vulcanize
|
2018-11-23 18:12:24 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-11-24 04:26:07 +00:00
|
|
|
package mocks
|
2018-11-23 18:12:24 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2019-03-11 16:19:18 +00:00
|
|
|
"strings"
|
2018-11-23 18:12:24 +00:00
|
|
|
|
2018-11-24 04:26:07 +00:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
|
|
2019-03-13 16:14:35 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/config"
|
2019-03-11 23:18:54 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants"
|
2018-11-23 18:12:24 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/filters"
|
|
|
|
)
|
|
|
|
|
|
|
|
var TransferBlock1 = core.Block{
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
|
|
|
|
Number: 6194633,
|
2019-03-27 04:05:30 +00:00
|
|
|
Transactions: []core.TransactionModel{{
|
2019-03-19 19:11:26 +00:00
|
|
|
GasLimit: 0,
|
|
|
|
GasPrice: 0,
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654aaa",
|
|
|
|
Nonce: 0,
|
2018-11-23 18:12:24 +00:00
|
|
|
Receipt: core.Receipt{
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654aaa",
|
|
|
|
ContractAddress: "",
|
2019-08-06 21:57:08 +00:00
|
|
|
Logs: []core.FullSyncLog{{
|
2018-11-23 18:12:24 +00:00
|
|
|
BlockNumber: 6194633,
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654aaa",
|
|
|
|
Address: constants.TusdContractAddress,
|
|
|
|
Topics: core.Topics{
|
|
|
|
constants.TransferEvent.Signature(),
|
|
|
|
"0x000000000000000000000000000000000000000000000000000000000000af21",
|
|
|
|
"0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
|
|
|
|
"",
|
|
|
|
},
|
|
|
|
Index: 1,
|
|
|
|
Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
|
|
|
|
}},
|
|
|
|
},
|
2019-03-19 19:11:26 +00:00
|
|
|
TxIndex: 0,
|
|
|
|
Value: "0",
|
2018-11-23 18:12:24 +00:00
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
|
|
|
var TransferBlock2 = core.Block{
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ooo",
|
|
|
|
Number: 6194634,
|
2019-03-27 04:05:30 +00:00
|
|
|
Transactions: []core.TransactionModel{{
|
2019-03-19 19:11:26 +00:00
|
|
|
GasLimit: 0,
|
|
|
|
GasPrice: 0,
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654eee",
|
|
|
|
Nonce: 0,
|
2018-11-23 18:12:24 +00:00
|
|
|
Receipt: core.Receipt{
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654eee",
|
|
|
|
ContractAddress: "",
|
2019-08-06 21:57:08 +00:00
|
|
|
Logs: []core.FullSyncLog{{
|
2018-11-23 18:12:24 +00:00
|
|
|
BlockNumber: 6194634,
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654eee",
|
|
|
|
Address: constants.TusdContractAddress,
|
|
|
|
Topics: core.Topics{
|
|
|
|
constants.TransferEvent.Signature(),
|
|
|
|
"0x000000000000000000000000000000000000000000000000000000000000af21",
|
|
|
|
"0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
|
|
|
|
"",
|
|
|
|
},
|
|
|
|
Index: 1,
|
|
|
|
Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
|
|
|
|
}},
|
|
|
|
},
|
2019-03-19 19:11:26 +00:00
|
|
|
TxIndex: 0,
|
|
|
|
Value: "0",
|
2018-11-23 18:12:24 +00:00
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
2018-12-14 17:52:02 +00:00
|
|
|
var NewOwnerBlock1 = core.Block{
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ppp",
|
|
|
|
Number: 6194635,
|
2019-03-27 04:05:30 +00:00
|
|
|
Transactions: []core.TransactionModel{{
|
2019-03-19 19:11:26 +00:00
|
|
|
GasLimit: 0,
|
|
|
|
GasPrice: 0,
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654bbb",
|
|
|
|
Nonce: 0,
|
2018-12-14 17:52:02 +00:00
|
|
|
Receipt: core.Receipt{
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654bbb",
|
|
|
|
ContractAddress: "",
|
2019-08-06 21:57:08 +00:00
|
|
|
Logs: []core.FullSyncLog{{
|
2018-12-14 17:52:02 +00:00
|
|
|
BlockNumber: 6194635,
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654bbb",
|
|
|
|
Address: constants.EnsContractAddress,
|
|
|
|
Topics: core.Topics{
|
|
|
|
constants.NewOwnerEvent.Signature(),
|
|
|
|
"0x0000000000000000000000000000000000000000000000000000c02aaa39b223",
|
|
|
|
"0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
|
|
|
|
"",
|
|
|
|
},
|
|
|
|
Index: 1,
|
|
|
|
Data: "0x000000000000000000000000000000000000000000000000000000000000af21",
|
|
|
|
}},
|
|
|
|
},
|
2019-03-19 19:11:26 +00:00
|
|
|
TxIndex: 0,
|
|
|
|
Value: "0",
|
2018-12-14 17:52:02 +00:00
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
|
|
|
var NewOwnerBlock2 = core.Block{
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ggg",
|
|
|
|
Number: 6194636,
|
2019-03-27 04:05:30 +00:00
|
|
|
Transactions: []core.TransactionModel{{
|
2019-03-19 19:11:26 +00:00
|
|
|
GasLimit: 0,
|
|
|
|
GasPrice: 0,
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654lll",
|
|
|
|
Nonce: 0,
|
2018-12-14 17:52:02 +00:00
|
|
|
Receipt: core.Receipt{
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654lll",
|
|
|
|
ContractAddress: "",
|
2019-08-06 21:57:08 +00:00
|
|
|
Logs: []core.FullSyncLog{{
|
2018-12-14 17:52:02 +00:00
|
|
|
BlockNumber: 6194636,
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654lll",
|
|
|
|
Address: constants.EnsContractAddress,
|
|
|
|
Topics: core.Topics{
|
|
|
|
constants.NewOwnerEvent.Signature(),
|
|
|
|
"0x0000000000000000000000000000000000000000000000000000c02aaa39b223",
|
|
|
|
"0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba400",
|
|
|
|
"",
|
|
|
|
},
|
|
|
|
Index: 1,
|
|
|
|
Data: "0x000000000000000000000000000000000000000000000000000000000000af21",
|
|
|
|
}},
|
|
|
|
},
|
2019-03-19 19:11:26 +00:00
|
|
|
TxIndex: 0,
|
|
|
|
Value: "0",
|
2018-12-14 17:52:02 +00:00
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
2018-11-23 18:12:24 +00:00
|
|
|
var ExpectedTransferFilter = filters.LogFilter{
|
2019-02-13 19:04:07 +00:00
|
|
|
Name: constants.TusdContractAddress + "_" + "Transfer",
|
2018-11-23 18:12:24 +00:00
|
|
|
Address: constants.TusdContractAddress,
|
|
|
|
ToBlock: -1,
|
|
|
|
FromBlock: 6194634,
|
|
|
|
Topics: core.Topics{constants.TransferEvent.Signature()},
|
|
|
|
}
|
|
|
|
|
|
|
|
var ExpectedApprovalFilter = filters.LogFilter{
|
2019-02-13 19:04:07 +00:00
|
|
|
Name: constants.TusdContractAddress + "_" + "Approval",
|
2018-11-23 18:12:24 +00:00
|
|
|
Address: constants.TusdContractAddress,
|
|
|
|
ToBlock: -1,
|
|
|
|
FromBlock: 6194634,
|
|
|
|
Topics: core.Topics{constants.ApprovalEvent.Signature()},
|
|
|
|
}
|
|
|
|
|
|
|
|
var MockTranferEvent = core.WatchedEvent{
|
|
|
|
LogID: 1,
|
|
|
|
Name: constants.TransferEvent.String(),
|
|
|
|
BlockNumber: 5488076,
|
|
|
|
Address: constants.TusdContractAddress,
|
|
|
|
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
|
|
|
Index: 110,
|
|
|
|
Topic0: constants.TransferEvent.Signature(),
|
|
|
|
Topic1: "0x000000000000000000000000000000000000000000000000000000000000af21",
|
|
|
|
Topic2: "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
|
|
|
|
Topic3: "",
|
|
|
|
Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
|
|
|
|
}
|
|
|
|
|
|
|
|
var rawFakeHeader, _ = json.Marshal(core.Header{})
|
|
|
|
|
|
|
|
var MockHeader1 = core.Header{
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
|
|
|
|
BlockNumber: 6194632,
|
|
|
|
Raw: rawFakeHeader,
|
|
|
|
Timestamp: "50000000",
|
|
|
|
}
|
|
|
|
|
|
|
|
var MockHeader2 = core.Header{
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad456yui",
|
|
|
|
BlockNumber: 6194633,
|
|
|
|
Raw: rawFakeHeader,
|
|
|
|
Timestamp: "50000015",
|
|
|
|
}
|
|
|
|
|
|
|
|
var MockHeader3 = core.Header{
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
|
|
|
|
BlockNumber: 6194634,
|
|
|
|
Raw: rawFakeHeader,
|
2019-03-12 00:02:04 +00:00
|
|
|
Timestamp: "50000030",
|
|
|
|
}
|
|
|
|
|
|
|
|
var MockHeader4 = core.Header{
|
|
|
|
Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
|
|
|
|
BlockNumber: 6194635,
|
|
|
|
Raw: rawFakeHeader,
|
2018-11-23 18:12:24 +00:00
|
|
|
Timestamp: "50000030",
|
|
|
|
}
|
2018-11-24 04:26:07 +00:00
|
|
|
|
|
|
|
var MockTransferLog1 = types.Log{
|
|
|
|
Index: 1,
|
|
|
|
Address: common.HexToAddress(constants.TusdContractAddress),
|
|
|
|
BlockNumber: 5488076,
|
|
|
|
TxIndex: 110,
|
|
|
|
TxHash: common.HexToHash("0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae"),
|
|
|
|
Topics: []common.Hash{
|
|
|
|
common.HexToHash(constants.TransferEvent.Signature()),
|
|
|
|
common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000af21"),
|
|
|
|
common.HexToHash("0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391"),
|
|
|
|
},
|
|
|
|
Data: hexutil.MustDecode("0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe"),
|
|
|
|
}
|
|
|
|
|
|
|
|
var MockTransferLog2 = types.Log{
|
|
|
|
Index: 3,
|
|
|
|
Address: common.HexToAddress(constants.TusdContractAddress),
|
|
|
|
BlockNumber: 5488077,
|
|
|
|
TxIndex: 2,
|
2018-12-14 17:52:02 +00:00
|
|
|
TxHash: common.HexToHash("0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546df"),
|
2018-11-24 04:26:07 +00:00
|
|
|
Topics: []common.Hash{
|
|
|
|
common.HexToHash(constants.TransferEvent.Signature()),
|
|
|
|
common.HexToHash("0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391"),
|
|
|
|
common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000af21"),
|
|
|
|
},
|
|
|
|
Data: hexutil.MustDecode("0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe"),
|
|
|
|
}
|
|
|
|
|
|
|
|
var MockMintLog = types.Log{
|
|
|
|
Index: 10,
|
|
|
|
Address: common.HexToAddress(constants.TusdContractAddress),
|
2018-12-14 17:52:02 +00:00
|
|
|
BlockNumber: 5488080,
|
2018-11-24 04:26:07 +00:00
|
|
|
TxIndex: 50,
|
|
|
|
TxHash: common.HexToHash("0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6minty"),
|
|
|
|
Topics: []common.Hash{
|
|
|
|
common.HexToHash(constants.MintEvent.Signature()),
|
|
|
|
common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000af21"),
|
|
|
|
},
|
|
|
|
Data: hexutil.MustDecode("0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe"),
|
|
|
|
}
|
2018-12-14 17:52:02 +00:00
|
|
|
|
|
|
|
var MockNewOwnerLog1 = types.Log{
|
|
|
|
Index: 1,
|
|
|
|
Address: common.HexToAddress(constants.EnsContractAddress),
|
|
|
|
BlockNumber: 5488076,
|
|
|
|
TxIndex: 110,
|
|
|
|
TxHash: common.HexToHash("0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae"),
|
|
|
|
Topics: []common.Hash{
|
|
|
|
common.HexToHash(constants.NewOwnerEvent.Signature()),
|
|
|
|
common.HexToHash("0x000000000000000000000000c02aaa39b223helloa0e5c4f27ead9083c752553"),
|
|
|
|
common.HexToHash("0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391"),
|
|
|
|
},
|
|
|
|
Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000af21"),
|
|
|
|
}
|
|
|
|
|
|
|
|
var MockNewOwnerLog2 = types.Log{
|
|
|
|
Index: 3,
|
|
|
|
Address: common.HexToAddress(constants.EnsContractAddress),
|
|
|
|
BlockNumber: 5488077,
|
|
|
|
TxIndex: 2,
|
|
|
|
TxHash: common.HexToHash("0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546df"),
|
|
|
|
Topics: []common.Hash{
|
|
|
|
common.HexToHash(constants.NewOwnerEvent.Signature()),
|
|
|
|
common.HexToHash("0x000000000000000000000000c02aaa39b223helloa0e5c4f27ead9083c752553"),
|
|
|
|
common.HexToHash("0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba400"),
|
|
|
|
},
|
|
|
|
Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000af21"),
|
|
|
|
}
|
2019-03-11 16:19:18 +00:00
|
|
|
|
|
|
|
var ens = strings.ToLower(constants.EnsContractAddress)
|
|
|
|
var tusd = strings.ToLower(constants.TusdContractAddress)
|
|
|
|
|
2019-03-13 16:14:35 +00:00
|
|
|
var MockConfig = config.ContractConfig{
|
2019-03-11 16:19:18 +00:00
|
|
|
Network: "",
|
|
|
|
Addresses: map[string]bool{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": true,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
Abis: map[string]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": "fake_abi",
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
Events: map[string][]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": []string{"Transfer"},
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
Methods: map[string][]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": nil,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
MethodArgs: map[string][]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": nil,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
EventArgs: map[string][]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": nil,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-03-13 16:14:35 +00:00
|
|
|
var MockEmptyConfig = config.ContractConfig{
|
2019-03-11 16:19:18 +00:00
|
|
|
Network: "",
|
|
|
|
Addresses: map[string]bool{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": true,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
Abis: map[string]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": "fake_abi",
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
Events: map[string][]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": nil,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
Methods: map[string][]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": nil,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
MethodArgs: map[string][]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": nil,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
EventArgs: map[string][]string{
|
2019-03-13 16:14:35 +00:00
|
|
|
"0x1234567890abcdef": nil,
|
2019-03-11 16:19:18 +00:00
|
|
|
},
|
|
|
|
}
|