From 8105299f1aaea7be7efe4ed7f4a025c8ad1fe4c9 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 19 Sep 2022 10:07:00 +0700 Subject: [PATCH] gofumpt -w -l for code formatting --- bifrost/pkg/chainclients/bitcoin/bitcoin.go | 1 - .../pkg/chainclients/bitcoin/bitcoin_test.go | 78 +++++++++---------- .../mock_pool_address_validator.go | 3 +- bifrost/signer/sign.go | 3 +- bifrost/thorclient/types/account_resp.go | 2 +- bifrost/tss/mock_thorchain_keymanager.go | 3 +- cmd/bifrost/health_test.go | 3 +- constants/constant_values_chaosnet.go | 1 + constants/constants_mocknet.go | 1 + constants/constants_testnet.go | 1 + constants/constants_testnet_test.go | 1 + x/thorchain/dummy_event_manager.go | 3 +- x/thorchain/dummy_gas_manager.go | 6 +- x/thorchain/dummy_observer_manager.go | 6 +- x/thorchain/event_manager.go | 3 +- x/thorchain/handler.go | 12 ++- x/thorchain/handler_errata_tx_test.go | 4 +- x/thorchain/handler_native_tx.go | 3 +- x/thorchain/handler_observed_txin.go | 3 +- x/thorchain/handler_observed_txout.go | 3 +- x/thorchain/handler_stake_chaosnet_test.go | 1 + x/thorchain/handler_tss_test.go | 14 ++-- x/thorchain/stake.go | 3 +- x/thorchain/swap.go | 6 +- x/thorchain/swap_test.go | 10 +-- x/thorchain/types/msg_tss_sign_fail_test.go | 4 +- x/thorchain/types/type_marker.go | 2 +- .../types/type_tss_keysign_fail_test.go | 6 +- x/thorchain/validator_manager_dummy_test.go | 6 +- x/thorchain/vault_manager_test.go | 4 +- 30 files changed, 100 insertions(+), 96 deletions(-) diff --git a/bifrost/pkg/chainclients/bitcoin/bitcoin.go b/bifrost/pkg/chainclients/bitcoin/bitcoin.go index 5ba3dff65..6f4b13c3b 100644 --- a/bifrost/pkg/chainclients/bitcoin/bitcoin.go +++ b/bifrost/pkg/chainclients/bitcoin/bitcoin.go @@ -397,7 +397,6 @@ func (c *Client) extractTxs(block *btcjson.GetBlockVerboseTxResult) (types.TxIn, // - vout:0 doesn't have address // - count vouts > 4 // - count vouts with coins (value) > 2 -// func (c *Client) ignoreTx(tx *btcjson.TxRawResult) bool { if len(tx.Vin) == 0 || len(tx.Vout) == 0 || len(tx.Vout) > 4 { return true diff --git a/bifrost/pkg/chainclients/bitcoin/bitcoin_test.go b/bifrost/pkg/chainclients/bitcoin/bitcoin_test.go index 86a7c4612..8ea90c6e8 100644 --- a/bifrost/pkg/chainclients/bitcoin/bitcoin_test.go +++ b/bifrost/pkg/chainclients/bitcoin/bitcoin_test.go @@ -167,7 +167,7 @@ func (s *BitcoinSuite) TestFetchTxs(c *C) { func (s *BitcoinSuite) TestGetSender(c *C) { tx := btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "31f8699ce9028e9cd37f8a6d58a79e614a96e3fdd0f58be5fc36d2d95484716f", Vout: 0, }, @@ -186,7 +186,7 @@ func (s *BitcoinSuite) TestGetSender(c *C) { func (s *BitcoinSuite) TestGetMemo(c *C) { tx := btcjson.TxRawResult{ Vout: []btcjson.Vout{ - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -199,12 +199,12 @@ func (s *BitcoinSuite) TestGetMemo(c *C) { tx = btcjson.TxRawResult{ Vout: []btcjson.Vout{ - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 737761703a6574682e3078633534633135313236393646334541373935366264396144343130383138654563414443466666663a30786335346331353132363936463345413739353662643961443431", }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 30383138654563414443466666663a3130303030303030303030", }, @@ -227,19 +227,19 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { // valid tx that will NOT be ignored tx := btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "24ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Vout: 0, }, }, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0.12345678, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{"tb1qkq7weysjn6ljc2ywmjmwp8ttcckg8yyxjdz5k6"}, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -252,7 +252,7 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { // invalid tx missing Vout tx = btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "24ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Vout: 0, }, @@ -265,19 +265,19 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { // invalid tx missing vout[0].Value == no coins tx = btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "24ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Vout: 0, }, }, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{"tb1qkq7weysjn6ljc2ywmjmwp8ttcckg8yyxjdz5k6"}, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -290,19 +290,19 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { // invalid tx missing vin[0].Txid means coinbase tx = btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "", Vout: 0, }, }, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0.1234565, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{"tb1qkq7weysjn6ljc2ywmjmwp8ttcckg8yyxjdz5k6"}, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -316,13 +316,13 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { tx = btcjson.TxRawResult{ Vin: []btcjson.Vin{}, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0.1234565, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{"tb1qkq7weysjn6ljc2ywmjmwp8ttcckg8yyxjdz5k6"}, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -335,13 +335,13 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { // invalid tx multiple vout[0].Addresses tx = btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "24ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Vout: 0, }, }, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0.1234565, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{ @@ -350,7 +350,7 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { }, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -363,13 +363,13 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { // invalid tx > 2 vout with coins we only expect 2 max tx = btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "24ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Vout: 0, }, }, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0.1234565, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{ @@ -377,7 +377,7 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { }, }, }, - btcjson.Vout{ + { Value: 0.1234565, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{ @@ -385,7 +385,7 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { }, }, }, - btcjson.Vout{ + { Value: 0.1234565, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{ @@ -393,7 +393,7 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { }, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -406,13 +406,13 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { // valid tx == 2 vout with coins, 1 to vault, 1 with change back to user tx = btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "24ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Vout: 0, }, }, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0.1234565, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{ @@ -420,7 +420,7 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { }, }, }, - btcjson.Vout{ + { Value: 0.1234565, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{ @@ -428,7 +428,7 @@ func (s *BitcoinSuite) TestIgnoreTx(c *C) { }, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -443,19 +443,19 @@ func (s *BitcoinSuite) TestGetGas(c *C) { // vin[0] returns value 0.19590108 tx := btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "24ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Vout: 0, }, }, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0.12345678, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{"tb1qkq7weysjn6ljc2ywmjmwp8ttcckg8yyxjdz5k6"}, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -468,25 +468,25 @@ func (s *BitcoinSuite) TestGetGas(c *C) { tx = btcjson.TxRawResult{ Vin: []btcjson.Vin{ - btcjson.Vin{ + { Txid: "5b0876dcc027d2f0c671fc250460ee388df39697c3ff082007b6ddd9cb9a7513", Vout: 1, }, }, Vout: []btcjson.Vout{ - btcjson.Vout{ + { Value: 0.00195384, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{"tb1qkq7weysjn6ljc2ywmjmwp8ttcckg8yyxjdz5k6"}, }, }, - btcjson.Vout{ + { Value: 1.49655603, ScriptPubKey: btcjson.ScriptPubKeyResult{ Addresses: []string{"tb1qkq7weysjn6ljc2ywmjmwp8ttcckg8yyxjdz5k6"}, }, }, - btcjson.Vout{ + { ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: "OP_RETURN 74686f72636861696e3a636f6e736f6c6964617465", }, @@ -563,7 +563,7 @@ func (s *BitcoinSuite) TestOnObservedTxIn(c *C) { Count: "1", Chain: common.BTCChain, TxArray: []types.TxInItem{ - types.TxInItem{ + { Tx: "31f8699ce9028e9cd37f8a6d58a79e614a96e3fdd0f58be5fc36d2d95484716f", Sender: "bc1q2gjc0rnhy4nrxvuklk6ptwkcs9kcr59mcl2q9j", To: "bc1q0s4mg25tu6termrk8egltfyme4q7sg3h0e56p3", @@ -594,7 +594,7 @@ func (s *BitcoinSuite) TestOnObservedTxIn(c *C) { Count: "1", Chain: common.BTCChain, TxArray: []types.TxInItem{ - types.TxInItem{ + { Tx: "24ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Sender: "bc1q0s4mg25tu6termrk8egltfyme4q7sg3h0e56p3", To: "bc1q2gjc0rnhy4nrxvuklk6ptwkcs9kcr59mcl2q9j", @@ -625,7 +625,7 @@ func (s *BitcoinSuite) TestOnObservedTxIn(c *C) { Count: "2", Chain: common.BTCChain, TxArray: []types.TxInItem{ - types.TxInItem{ + { Tx: "44ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Sender: "bc1q0s4mg25tu6termrk8egltfyme4q7sg3h0e56p3", To: "bc1q2gjc0rnhy4nrxvuklk6ptwkcs9kcr59mcl2q9j", @@ -635,7 +635,7 @@ func (s *BitcoinSuite) TestOnObservedTxIn(c *C) { Memo: "MEMO", ObservedVaultPubKey: pkey, }, - types.TxInItem{ + { Tx: "54ed2d26fd5d4e0e8fa86633e40faf1bdfc8d1903b1cd02855286312d48818a2", Sender: "bc1q0s4mg25tu6termrk8egltfyme4q7sg3h0e56p3", To: "bc1q2gjc0rnhy4nrxvuklk6ptwkcs9kcr59mcl2q9j", diff --git a/bifrost/pubkeymanager/mock_pool_address_validator.go b/bifrost/pubkeymanager/mock_pool_address_validator.go index 2dcef669a..5a7c610b9 100644 --- a/bifrost/pubkeymanager/mock_pool_address_validator.go +++ b/bifrost/pubkeymanager/mock_pool_address_validator.go @@ -16,8 +16,7 @@ var ( validpb = "thorpub1addwnpepqfgfxharps79pqv8fv9ndqh90smw8c3slrtrssn58ryc5g3p9sx856x07yn" ) -type MockPoolAddressValidator struct { -} +type MockPoolAddressValidator struct{} func NewMockPoolAddressValidator() *MockPoolAddressValidator { return &MockPoolAddressValidator{} diff --git a/bifrost/signer/sign.go b/bifrost/signer/sign.go index c00676e5c..077e63423 100644 --- a/bifrost/signer/sign.go +++ b/bifrost/signer/sign.go @@ -54,7 +54,8 @@ func NewSigner(cfg config.SignerConfiguration, tssServer *tssp.TssServer, tssCfg config.TSSConfiguration, chains map[common.Chain]chainclients.ChainClient, - m *metrics.Metrics) (*Signer, error) { + m *metrics.Metrics, +) (*Signer, error) { storage, err := NewSignerStore(cfg.SignerDbPath, thorchainBridge.GetConfig().SignerPasswd) if err != nil { return nil, fmt.Errorf("fail to create thorchain scan storage: %w", err) diff --git a/bifrost/thorclient/types/account_resp.go b/bifrost/thorclient/types/account_resp.go index 590da3812..e3eab6c10 100644 --- a/bifrost/thorclient/types/account_resp.go +++ b/bifrost/thorclient/types/account_resp.go @@ -1,6 +1,6 @@ package types -/// AccountResp the response from thorclient +// / AccountResp the response from thorclient type AccountResp struct { Height string `json:"height"` Result struct { diff --git a/bifrost/tss/mock_thorchain_keymanager.go b/bifrost/tss/mock_thorchain_keymanager.go index 04cd60bae..f787573e2 100644 --- a/bifrost/tss/mock_thorchain_keymanager.go +++ b/bifrost/tss/mock_thorchain_keymanager.go @@ -13,8 +13,7 @@ import ( ) // MockThorchainKeymanager is to mock the TSS , so as we could test it -type MockThorchainKeyManager struct { -} +type MockThorchainKeyManager struct{} func (k *MockThorchainKeyManager) Sign(tx.StdSignMsg) ([]byte, error) { return nil, nil diff --git a/cmd/bifrost/health_test.go b/cmd/bifrost/health_test.go index ac562e147..d7fd61f88 100644 --- a/cmd/bifrost/health_test.go +++ b/cmd/bifrost/health_test.go @@ -62,8 +62,7 @@ func (mts *MockTssServer) GetStatus() common.TssStatus { } } -type HealthServerTestSuite struct { -} +type HealthServerTestSuite struct{} var _ = Suite(&HealthServerTestSuite{}) diff --git a/constants/constant_values_chaosnet.go b/constants/constant_values_chaosnet.go index c5807ffb5..fb5059465 100644 --- a/constants/constant_values_chaosnet.go +++ b/constants/constant_values_chaosnet.go @@ -1,3 +1,4 @@ +//go:build chaosnet // +build chaosnet // For internal testing and mockneting diff --git a/constants/constants_mocknet.go b/constants/constants_mocknet.go index 49992a040..62efb2eee 100644 --- a/constants/constants_mocknet.go +++ b/constants/constants_mocknet.go @@ -1,3 +1,4 @@ +//go:build mocknet // +build mocknet // For internal testing and mockneting diff --git a/constants/constants_testnet.go b/constants/constants_testnet.go index 6a86740a1..8550480be 100644 --- a/constants/constants_testnet.go +++ b/constants/constants_testnet.go @@ -1,3 +1,4 @@ +//go:build testnet // +build testnet // For Public TestNet diff --git a/constants/constants_testnet_test.go b/constants/constants_testnet_test.go index 150365c1d..d29f46228 100644 --- a/constants/constants_testnet_test.go +++ b/constants/constants_testnet_test.go @@ -1,3 +1,4 @@ +//go:build testnet // +build testnet package constants diff --git a/x/thorchain/dummy_event_manager.go b/x/thorchain/dummy_event_manager.go index ec670e3ba..81c6b30d1 100644 --- a/x/thorchain/dummy_event_manager.go +++ b/x/thorchain/dummy_event_manager.go @@ -8,8 +8,7 @@ import ( ) // DummyEventMgr used for test purpose , and it implement EventManager interface -type DummyEventMgr struct { -} +type DummyEventMgr struct{} func NewDummyEventMgr() *DummyEventMgr { return &DummyEventMgr{} diff --git a/x/thorchain/dummy_gas_manager.go b/x/thorchain/dummy_gas_manager.go index c7a32a80a..7f9275a9b 100644 --- a/x/thorchain/dummy_gas_manager.go +++ b/x/thorchain/dummy_gas_manager.go @@ -7,8 +7,7 @@ import ( "gitlab.com/thorchain/thornode/common" ) -type DummyGasManager struct { -} +type DummyGasManager struct{} func NewDummyGasManager() *DummyGasManager { return &DummyGasManager{} @@ -20,8 +19,7 @@ func (m *DummyGasManager) AddGasAsset(gas common.Gas) func (m *DummyGasManager) GetGas() common.Gas { return nil } func (m *DummyGasManager) ProcessGas(ctx sdk.Context, keeper Keeper) {} -type DummyVersionedGasMgr struct { -} +type DummyVersionedGasMgr struct{} func NewDummyVersionedGasMgr() *DummyVersionedGasMgr { return &DummyVersionedGasMgr{} diff --git a/x/thorchain/dummy_observer_manager.go b/x/thorchain/dummy_observer_manager.go index 00cf8416d..cf649744f 100644 --- a/x/thorchain/dummy_observer_manager.go +++ b/x/thorchain/dummy_observer_manager.go @@ -7,8 +7,7 @@ import ( "gitlab.com/thorchain/thornode/common" ) -type DummyObserverManager struct { -} +type DummyObserverManager struct{} func NewDummyObserverManager() *DummyObserverManager { return &DummyObserverManager{} @@ -19,8 +18,7 @@ func (m *DummyObserverManager) EndBlock(ctx sdk.Context, keeper Keeper) func (m *DummyObserverManager) AppendObserver(chain common.Chain, addrs []sdk.AccAddress) {} func (m *DummyObserverManager) List() []sdk.AccAddress { return nil } -type DummyVersionedObserverMgr struct { -} +type DummyVersionedObserverMgr struct{} func NewDummyVersionedObserverMgr() *DummyVersionedObserverMgr { return &DummyVersionedObserverMgr{} diff --git a/x/thorchain/event_manager.go b/x/thorchain/event_manager.go index 33430a209..80b06b780 100644 --- a/x/thorchain/event_manager.go +++ b/x/thorchain/event_manager.go @@ -29,8 +29,7 @@ type EventManager interface { } // EventMgr implement EventManager interface -type EventMgr struct { -} +type EventMgr struct{} // NewEventMgr create a new instance of EventMgr func NewEventMgr() *EventMgr { diff --git a/x/thorchain/handler.go b/x/thorchain/handler.go index 69d5ece7c..2dbfbe777 100644 --- a/x/thorchain/handler.go +++ b/x/thorchain/handler.go @@ -64,7 +64,8 @@ func NewExternalHandler(keeper Keeper, versionedVaultManager VersionedVaultManager, versionedObserverManager VersionedObserverManager, versionedGasMgr VersionedGasManager, - versionedEventManager VersionedEventManager) sdk.Handler { + versionedEventManager VersionedEventManager, +) sdk.Handler { handlerMap := getHandlerMapping(keeper, versionedTxOutStore, validatorMgr, versionedVaultManager, versionedObserverManager, versionedGasMgr, versionedEventManager) return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { @@ -93,7 +94,8 @@ func getHandlerMapping(keeper Keeper, versionedVaultManager VersionedVaultManager, versionedObserverManager VersionedObserverManager, versionedGasMgr VersionedGasManager, - versionedEventManager VersionedEventManager) map[string]MsgHandler { + versionedEventManager VersionedEventManager, +) map[string]MsgHandler { // New arch handlers m := make(map[string]MsgHandler) m[MsgTssPool{}.Type()] = NewTssHandler(keeper, versionedVaultManager) @@ -117,7 +119,8 @@ func NewInternalHandler(keeper Keeper, versionedVaultManager VersionedVaultManager, versionedObserverManager VersionedObserverManager, versionedGasMgr VersionedGasManager, - versionedEventManager VersionedEventManager) sdk.Handler { + versionedEventManager VersionedEventManager, +) sdk.Handler { handlerMap := getInternalHandlerMapping(keeper, versionedTxOutStore, validatorMgr, versionedVaultManager, versionedObserverManager, versionedGasMgr, versionedEventManager) return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { @@ -141,7 +144,8 @@ func getInternalHandlerMapping(keeper Keeper, versionedVaultManager VersionedVaultManager, versionedObserverManager VersionedObserverManager, versionedGasMgr VersionedGasManager, - versionedEventManager VersionedEventManager) map[string]MsgHandler { + versionedEventManager VersionedEventManager, +) map[string]MsgHandler { // New arch handlers m := make(map[string]MsgHandler) m[MsgOutboundTx{}.Type()] = NewOutboundTxHandler(keeper, versionedEventManager) diff --git a/x/thorchain/handler_errata_tx_test.go b/x/thorchain/handler_errata_tx_test.go index 6beb1ffa6..5bd1ba379 100644 --- a/x/thorchain/handler_errata_tx_test.go +++ b/x/thorchain/handler_errata_tx_test.go @@ -127,13 +127,13 @@ func (s *HandlerErrataTxSuite) TestHandle(c *C) { BalanceAsset: sdk.NewUint(100 * common.One), }, stakers: []Staker{ - Staker{ + { RuneAddress: addr, LastStakeHeight: 5, Units: totalUnits.QuoUint64(2), PendingRune: sdk.ZeroUint(), }, - Staker{ + { RuneAddress: GetRandomBNBAddress(), LastStakeHeight: 10, Units: totalUnits.QuoUint64(2), diff --git a/x/thorchain/handler_native_tx.go b/x/thorchain/handler_native_tx.go index 461d9bfad..28703b931 100644 --- a/x/thorchain/handler_native_tx.go +++ b/x/thorchain/handler_native_tx.go @@ -28,7 +28,8 @@ func NewNativeTxHandler(keeper Keeper, validatorMgr VersionedValidatorManager, versionedVaultManager VersionedVaultManager, versionedGasMgr VersionedGasManager, - versionedEventManager VersionedEventManager) NativeTxHandler { + versionedEventManager VersionedEventManager, +) NativeTxHandler { return NativeTxHandler{ keeper: keeper, versionedTxOutStore: versionedTxOutStore, diff --git a/x/thorchain/handler_observed_txin.go b/x/thorchain/handler_observed_txin.go index c47093565..2e7bbeabf 100644 --- a/x/thorchain/handler_observed_txin.go +++ b/x/thorchain/handler_observed_txin.go @@ -28,7 +28,8 @@ func NewObservedTxInHandler(keeper Keeper, validatorMgr VersionedValidatorManager, versionedVaultManager VersionedVaultManager, versionedGasMgr VersionedGasManager, - versionedEventManager VersionedEventManager) ObservedTxInHandler { + versionedEventManager VersionedEventManager, +) ObservedTxInHandler { return ObservedTxInHandler{ keeper: keeper, versionedTxOutStore: versionedTxOutStore, diff --git a/x/thorchain/handler_observed_txout.go b/x/thorchain/handler_observed_txout.go index 01d88de79..3698bdca1 100644 --- a/x/thorchain/handler_observed_txout.go +++ b/x/thorchain/handler_observed_txout.go @@ -26,7 +26,8 @@ func NewObservedTxOutHandler(keeper Keeper, validatorMgr VersionedValidatorManager, versionedVaultManager VersionedVaultManager, versionedGasMgr VersionedGasManager, - versionedEventManager VersionedEventManager) ObservedTxOutHandler { + versionedEventManager VersionedEventManager, +) ObservedTxOutHandler { return ObservedTxOutHandler{ keeper: keeper, versionedTxOutStore: txOutStore, diff --git a/x/thorchain/handler_stake_chaosnet_test.go b/x/thorchain/handler_stake_chaosnet_test.go index d063ecb12..77aeb7e6d 100644 --- a/x/thorchain/handler_stake_chaosnet_test.go +++ b/x/thorchain/handler_stake_chaosnet_test.go @@ -1,3 +1,4 @@ +//go:build chaosnet // +build chaosnet package thorchain diff --git a/x/thorchain/handler_tss_test.go b/x/thorchain/handler_tss_test.go index 2ff47224a..9b58f672c 100644 --- a/x/thorchain/handler_tss_test.go +++ b/x/thorchain/handler_tss_test.go @@ -328,7 +328,7 @@ func (s *HandlerTssSuite) TestTssHandler(c *C) { b := blame.Blame{ FailReason: "who knows", BlameNodes: []blame.Node{ - blame.Node{Pubkey: "whatever"}, + {Pubkey: "whatever"}, }, } tssMsg := NewMsgTssPool(helper.members, GetRandomPubKey(), AsgardKeygen, helper.ctx.BlockHeight(), b, common.Chains{common.RuneAsset().Chain}, helper.signer) @@ -363,7 +363,7 @@ func (s *HandlerTssSuite) TestTssHandler(c *C) { b := blame.Blame{ FailReason: "who knows", BlameNodes: []blame.Node{ - blame.Node{Pubkey: helper.members[3].String()}, + {Pubkey: helper.members[3].String()}, }, } tssMsg := NewMsgTssPool(helper.members, GetRandomPubKey(), AsgardKeygen, helper.ctx.BlockHeight(), b, common.Chains{common.RuneAsset().Chain}, helper.signer) @@ -412,7 +412,7 @@ func (s *HandlerTssSuite) TestTssHandler(c *C) { b := blame.Blame{ FailReason: "who knows", BlameNodes: []blame.Node{ - blame.Node{Pubkey: helper.members[3].String()}, + {Pubkey: helper.members[3].String()}, }, } tssMsg := NewMsgTssPool(helper.members, GetRandomPubKey(), AsgardKeygen, helper.ctx.BlockHeight(), b, common.Chains{common.RuneAsset().Chain}, helper.signer) @@ -444,7 +444,7 @@ func (s *HandlerTssSuite) TestTssHandler(c *C) { b := blame.Blame{ FailReason: "who knows", BlameNodes: []blame.Node{ - blame.Node{Pubkey: helper.members[3].String()}, + {Pubkey: helper.members[3].String()}, }, } tssMsg := NewMsgTssPool(helper.members, GetRandomPubKey(), AsgardKeygen, helper.ctx.BlockHeight(), b, common.Chains{common.RuneAsset().Chain}, helper.signer) @@ -487,7 +487,7 @@ func (s *HandlerTssSuite) TestTssHandler(c *C) { b := blame.Blame{ FailReason: "who knows", BlameNodes: []blame.Node{ - blame.Node{Pubkey: helper.members[3].String()}, + {Pubkey: helper.members[3].String()}, }, } tssMsg := NewMsgTssPool(helper.members, GetRandomPubKey(), AsgardKeygen, helper.ctx.BlockHeight(), b, common.Chains{common.RuneAsset().Chain}, helper.signer) @@ -521,7 +521,7 @@ func (s *HandlerTssSuite) TestTssHandler(c *C) { b := blame.Blame{ FailReason: "who knows", BlameNodes: []blame.Node{ - blame.Node{Pubkey: helper.members[3].String()}, + {Pubkey: helper.members[3].String()}, }, } tssMsg := NewMsgTssPool(helper.members, GetRandomPubKey(), AsgardKeygen, helper.ctx.BlockHeight(), b, common.Chains{common.RuneAsset().Chain}, helper.signer) @@ -550,7 +550,7 @@ func (s *HandlerTssSuite) TestTssHandler(c *C) { b := blame.Blame{ FailReason: "who knows", BlameNodes: []blame.Node{ - blame.Node{Pubkey: helper.members[3].String()}, + {Pubkey: helper.members[3].String()}, }, } tssMsg := NewMsgTssPool(helper.members, GetRandomPubKey(), AsgardKeygen, helper.ctx.BlockHeight(), b, common.Chains{common.RuneAsset().Chain}, helper.signer) diff --git a/x/thorchain/stake.go b/x/thorchain/stake.go index 1a27a40c8..6e53374bc 100644 --- a/x/thorchain/stake.go +++ b/x/thorchain/stake.go @@ -37,7 +37,8 @@ func stake(ctx sdk.Context, keeper Keeper, asset common.Asset, stakeRuneAmount, stakeAssetAmount sdk.Uint, runeAddr, assetAddr common.Address, - requestTxHash common.TxID, constAccessor constants.ConstantValues) (sdk.Uint, sdk.Error) { + requestTxHash common.TxID, constAccessor constants.ConstantValues, +) (sdk.Uint, sdk.Error) { ctx.Logger().Info(fmt.Sprintf("%s staking %s %s", asset, stakeRuneAmount, stakeAssetAmount)) if err := validateStakeMessage(ctx, keeper, asset, requestTxHash, runeAddr, assetAddr); err != nil { ctx.Logger().Error("stake message fail validation", "error", err) diff --git a/x/thorchain/swap.go b/x/thorchain/swap.go index 52dc275c4..c0f617b29 100644 --- a/x/thorchain/swap.go +++ b/x/thorchain/swap.go @@ -49,7 +49,8 @@ func swap(ctx sdk.Context, target common.Asset, destination common.Address, tradeTarget sdk.Uint, - transactionFee sdk.Uint) (sdk.Uint, []EventSwap, sdk.Error) { + transactionFee sdk.Uint, +) (sdk.Uint, []EventSwap, sdk.Error) { var swapEvents []EventSwap if err := validateMessage(tx, target, destination); err != nil { @@ -112,7 +113,8 @@ func swapOne(ctx sdk.Context, target common.Asset, destination common.Address, tradeTarget sdk.Uint, - transactionFee sdk.Uint) (amt sdk.Uint, poolResult Pool, evt EventSwap, swapErr sdk.Error) { + transactionFee sdk.Uint, +) (amt sdk.Uint, poolResult Pool, evt EventSwap, swapErr sdk.Error) { source := tx.Coins[0].Asset amount := tx.Coins[0].Amount diff --git a/x/thorchain/swap_test.go b/x/thorchain/swap_test.go index 5d49b7224..796ee6249 100644 --- a/x/thorchain/swap_test.go +++ b/x/thorchain/swap_test.go @@ -199,7 +199,7 @@ func (s *SwapSuite) TestSwap(c *C) { tradeTarget: sdk.ZeroUint(), expectedErr: nil, events: []Event{ - Event{ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don't know", Coins: common.Coins{common.NewCoin(common.RuneAsset(), sdk.NewUint(5000000000))}, Gas: common.Gas{common.NewCoin(common.BNBAsset, sdk.NewUint(37500))}}}, + {ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don't know", Coins: common.Coins{common.NewCoin(common.RuneAsset(), sdk.NewUint(5000000000))}, Gas: common.Gas{common.NewCoin(common.BNBAsset, sdk.NewUint(37500))}}}, }, }, { @@ -226,7 +226,7 @@ func (s *SwapSuite) TestSwap(c *C) { tradeTarget: sdk.ZeroUint(), expectedErr: nil, events: []Event{ - Event{ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don'tknow", Coins: common.Coins{common.NewCoin(common.RuneAsset(), sdk.NewUint(800000000))}, Gas: common.Gas{common.NewCoin(common.BNBAsset, sdk.NewUint(37500))}}}, + {ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don'tknow", Coins: common.Coins{common.NewCoin(common.RuneAsset(), sdk.NewUint(800000000))}, Gas: common.Gas{common.NewCoin(common.BNBAsset, sdk.NewUint(37500))}}}, }, }, { @@ -241,7 +241,7 @@ func (s *SwapSuite) TestSwap(c *C) { tradeTarget: sdk.NewUint(453514738), expectedErr: nil, events: []Event{ - Event{ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don'tknow", Coins: common.Coins{common.NewCoin(common.RuneAsset(), sdk.NewUint(500000000))}, Gas: common.Gas{common.NewCoin(common.BNBAsset, sdk.NewUint(37500))}}}, + {ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don'tknow", Coins: common.Coins{common.NewCoin(common.RuneAsset(), sdk.NewUint(500000000))}, Gas: common.Gas{common.NewCoin(common.BNBAsset, sdk.NewUint(37500))}}}, }, }, { @@ -256,8 +256,8 @@ func (s *SwapSuite) TestSwap(c *C) { tradeTarget: sdk.NewUint(415017809), expectedErr: nil, events: []Event{ - Event{ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don'tknow", Coins: common.Coins{common.NewCoin(common.BTCAsset, sdk.NewUint(5*common.One))}, Gas: common.Gas{common.NewCoin(common.BNBAsset, sdk.NewUint(37500))}}}, - Event{ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don'tknow", Coins: common.Coins{common.NewCoin(common.RuneAsset(), sdk.NewUint(453514739))}, Gas: nil}}, + {ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don'tknow", Coins: common.Coins{common.NewCoin(common.BTCAsset, sdk.NewUint(5*common.One))}, Gas: common.Gas{common.NewCoin(common.BNBAsset, sdk.NewUint(37500))}}}, + {ID: 0, Height: 18, Type: "swap", InTx: common.Tx{ID: "hash", Chain: "BNB", FromAddress: "tester", ToAddress: "don'tknow", Coins: common.Coins{common.NewCoin(common.RuneAsset(), sdk.NewUint(453514739))}, Gas: nil}}, }, }, } diff --git a/x/thorchain/types/msg_tss_sign_fail_test.go b/x/thorchain/types/msg_tss_sign_fail_test.go index be71255fa..aea2eb606 100644 --- a/x/thorchain/types/msg_tss_sign_fail_test.go +++ b/x/thorchain/types/msg_tss_sign_fail_test.go @@ -16,8 +16,8 @@ func (s MsgTssKeysignFailSuite) TestMsgTssKeysignFail(c *C) { b := blame.Blame{ FailReason: "fail to TSS sign", BlameNodes: []blame.Node{ - blame.Node{Pubkey: GetRandomPubKey().String()}, - blame.Node{Pubkey: GetRandomPubKey().String()}, + {Pubkey: GetRandomPubKey().String()}, + {Pubkey: GetRandomPubKey().String()}, }, } coins := common.Coins{ diff --git a/x/thorchain/types/type_marker.go b/x/thorchain/types/type_marker.go index dba40a011..391186445 100644 --- a/x/thorchain/types/type_marker.go +++ b/x/thorchain/types/type_marker.go @@ -37,7 +37,7 @@ func (mrks TxMarkers) Pop() (TxMarker, TxMarkers) { return TxMarker{}, nil } pop := mrks[0] - markers := mrks[1:len(mrks)] + markers := mrks[1:] return pop, markers } diff --git a/x/thorchain/types/type_tss_keysign_fail_test.go b/x/thorchain/types/type_tss_keysign_fail_test.go index 91c7e69bf..4f32ba196 100644 --- a/x/thorchain/types/type_tss_keysign_fail_test.go +++ b/x/thorchain/types/type_tss_keysign_fail_test.go @@ -14,9 +14,9 @@ var _ = Suite(&TypeTssKeysignFailTestSuite{}) func (s *TypeTssKeysignFailTestSuite) TestVoter(c *C) { nodes := []blame.Node{ - blame.Node{Pubkey: GetRandomPubKey().String()}, - blame.Node{Pubkey: GetRandomPubKey().String()}, - blame.Node{Pubkey: GetRandomPubKey().String()}, + {Pubkey: GetRandomPubKey().String()}, + {Pubkey: GetRandomPubKey().String()}, + {Pubkey: GetRandomPubKey().String()}, } b := blame.Blame{BlameNodes: nodes, FailReason: "fail to keysign"} m := NewMsgTssKeysignFail(1, b, "hello", common.Coins{common.NewCoin(common.BNBAsset, sdk.NewUint(100))}, GetRandomBech32Addr()) diff --git a/x/thorchain/validator_manager_dummy_test.go b/x/thorchain/validator_manager_dummy_test.go index 4f062556b..c60dc41fe 100644 --- a/x/thorchain/validator_manager_dummy_test.go +++ b/x/thorchain/validator_manager_dummy_test.go @@ -8,8 +8,7 @@ import ( "gitlab.com/thorchain/thornode/constants" ) -type VersionedValidatorDummyMgr struct { -} +type VersionedValidatorDummyMgr struct{} func NewVersionedValidatorDummyMgr() VersionedValidatorDummyMgr { return VersionedValidatorDummyMgr{} @@ -28,8 +27,7 @@ func (VersionedValidatorDummyMgr) RequestYggReturn(ctx sdk.Context, version semv } // ValidatorDummyMgr is to manage a list of validators , and rotate them -type ValidatorDummyMgr struct { -} +type ValidatorDummyMgr struct{} // NewValidatorDummyMgr create a new instance of ValidatorDummyMgr func NewValidatorDummyMgr() *ValidatorDummyMgr { diff --git a/x/thorchain/vault_manager_test.go b/x/thorchain/vault_manager_test.go index b7c0deef7..aa5859852 100644 --- a/x/thorchain/vault_manager_test.go +++ b/x/thorchain/vault_manager_test.go @@ -173,13 +173,13 @@ func (s *ValidatorManagerTestSuite) TestRagnarokChain(c *C) { addr := GetRandomRUNEAddress() stakers := []Staker{ - Staker{ + { RuneAddress: addr, LastStakeHeight: 5, Units: btcPool.PoolUnits.QuoUint64(2), PendingRune: sdk.ZeroUint(), }, - Staker{ + { RuneAddress: GetRandomRUNEAddress(), LastStakeHeight: 10, Units: btcPool.PoolUnits.QuoUint64(2),