code.vegaprotocol.io/vega@v0.79.0/wallet/tests/sc_taint_key_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 tests_test 17 18 import ( 19 "testing" 20 21 vgrand "code.vegaprotocol.io/vega/libs/rand" 22 23 "github.com/stretchr/testify/require" 24 ) 25 26 func TestTaintKeys(t *testing.T) { 27 // given 28 home := t.TempDir() 29 _, passphraseFilePath := NewPassphraseFile(t, home) 30 walletName := vgrand.RandomStr(5) 31 32 // when 33 createWalletResp, err := WalletCreate(t, []string{ 34 "--home", home, 35 "--output", "json", 36 "--wallet", walletName, 37 "--passphrase-file", passphraseFilePath, 38 }) 39 40 // then 41 require.NoError(t, err) 42 AssertCreateWallet(t, createWalletResp). 43 WithName(walletName). 44 LocatedUnder(home) 45 46 // when 47 err = KeyTaint(t, []string{ 48 "--home", home, 49 "--output", "json", 50 "--wallet", walletName, 51 "--passphrase-file", passphraseFilePath, 52 "--pubkey", createWalletResp.Key.PublicKey, 53 }) 54 55 // then 56 require.NoError(t, err) 57 58 // when 59 descResp, err := KeyDescribe(t, []string{ 60 "--home", home, 61 "--output", "json", 62 "--wallet", walletName, 63 "--passphrase-file", passphraseFilePath, 64 "--pubkey", createWalletResp.Key.PublicKey, 65 }) 66 67 // then 68 require.NoError(t, err) 69 AssertDescribeKey(t, descResp).WithTainted(true) 70 71 // when 72 err = KeyUntaint(t, []string{ 73 "--home", home, 74 "--output", "json", 75 "--wallet", walletName, 76 "--passphrase-file", passphraseFilePath, 77 "--pubkey", createWalletResp.Key.PublicKey, 78 }) 79 80 // then 81 require.NoError(t, err) 82 83 // when 84 descResp, err = KeyDescribe(t, []string{ 85 "--home", home, 86 "--output", "json", 87 "--wallet", walletName, 88 "--passphrase-file", passphraseFilePath, 89 "--pubkey", createWalletResp.Key.PublicKey, 90 }) 91 92 // then 93 require.NoError(t, err) 94 AssertDescribeKey(t, descResp).WithTainted(false) 95 }