Skip to content

Commit 41c8d2b

Browse files
authored
Merge pull request #161 from opentensor/fix/thewhaleking/hotkeypub-fix
Fix hotkeypub
2 parents 4df8f08 + 71eb567 commit 41c8d2b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/wallet.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,13 @@ impl Wallet {
320320
pub fn hotkeypub_file(&self) -> Result<Keyfile, KeyFileError> {
321321
// concatenate wallet path
322322
let wallet_path = self._path.join(&self.name);
323-
323+
let hotkeypub_name = format!("{}pub.txt", self.hotkey);
324324
// concatenate hotkeypub path
325-
let hotkeypub_path = wallet_path.join("hotkeypub.txt");
325+
let hotkeypub_path = wallet_path.join("hotkeys").join(&hotkeypub_name);
326326

327327
Keyfile::new(
328328
hotkeypub_path.to_string_lossy().into_owned(),
329-
Some("hotkeypub.txt".to_string()),
329+
Some(hotkeypub_name),
330330
false,
331331
)
332332
}
@@ -606,7 +606,7 @@ impl Wallet {
606606
let _hotkeypub = self
607607
._hotkeypub
608608
.clone()
609-
.ok_or_else(|| KeyFileError::Generic("Hotkey file doesn't exist.".to_string()))?;
609+
.ok_or_else(|| KeyFileError::Generic("Hotkeypub file doesn't exist.".to_string()))?;
610610
Ok(_hotkeypub)
611611
}
612612

tests/test_wallet.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,18 @@ def test_unlock_coldkeypub(mock_wallet):
156156
"""Verify that `unlock_coldkeypub` works correctly."""
157157
# Call
158158
coldkeypub = mock_wallet.unlock_coldkeypub()
159-
hotkeypub = mock_wallet.unlock_hotkeypub()
160159

161160
# Assertions
162161
assert coldkeypub.ss58_address == mock_wallet.get_coldkeypub().ss58_address
163162
assert coldkeypub.public_key == mock_wallet.get_coldkeypub().public_key
164163
assert coldkeypub.ss58_format == mock_wallet.get_coldkeypub().ss58_format
165164
assert coldkeypub.crypto_type == mock_wallet.get_coldkeypub().crypto_type
166-
165+
166+
def test_unlock_hotkeypub(mock_wallet):
167+
# Call
168+
hotkeypub = mock_wallet.unlock_hotkeypub()
169+
170+
# Assertations
167171
assert hotkeypub.ss58_address == mock_wallet.get_hotkeypub().ss58_address
168172
assert hotkeypub.public_key == mock_wallet.get_hotkeypub().public_key
169173
assert hotkeypub.ss58_format == mock_wallet.get_hotkeypub().ss58_format

0 commit comments

Comments
 (0)