code.vegaprotocol.io/vega@v0.79.0/core/nodewallets/nodewallets_test.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package nodewallets_test 17 18 import ( 19 "testing" 20 21 "code.vegaprotocol.io/vega/core/nodewallets" 22 ethnw "code.vegaprotocol.io/vega/core/nodewallets/eth" 23 vgnw "code.vegaprotocol.io/vega/core/nodewallets/vega" 24 25 "github.com/stretchr/testify/assert" 26 "github.com/stretchr/testify/require" 27 ) 28 29 func TestNodeWallet(t *testing.T) { 30 t.Run("Verify node wallets succeeds", testVerifyNodeWalletsSucceeds) 31 t.Run("Verify node wallets fails", testVerifyNodeWalletsFails) 32 } 33 34 func testVerifyNodeWalletsSucceeds(t *testing.T) { 35 nw := &nodewallets.NodeWallets{ 36 Vega: &vgnw.Wallet{}, 37 Ethereum: ðnw.Wallet{}, 38 Tendermint: &nodewallets.TendermintPubkey{}, 39 } 40 41 assert.NoError(t, nw.Verify()) 42 } 43 44 func testVerifyNodeWalletsFails(t *testing.T) { 45 tcs := []struct { 46 name string 47 expectedErr error 48 nw *nodewallets.NodeWallets 49 }{ 50 { 51 name: "with missing Ethereum wallet", 52 expectedErr: nodewallets.ErrEthereumWalletIsMissing, 53 nw: &nodewallets.NodeWallets{ 54 Vega: &vgnw.Wallet{}, 55 }, 56 }, { 57 name: "with missing Vega wallet", 58 expectedErr: nodewallets.ErrVegaWalletIsMissing, 59 nw: &nodewallets.NodeWallets{ 60 Ethereum: ðnw.Wallet{}, 61 }, 62 }, 63 } 64 65 for _, tc := range tcs { 66 t.Run(tc.name, func(tt *testing.T) { 67 require.EqualError(tt, tc.nw.Verify(), tc.expectedErr.Error()) 68 }) 69 } 70 }