-
Notifications
You must be signed in to change notification settings - Fork 459
Addresses generator (#1) #825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2af0c71
Addresses generator (#1)
6od9i 12b781f
- Grammar fixed
6od9i f30bd0e
- linter Trailing Whitespace Violation fixed
6od9i 9e9e48d
- closure style updated
6od9i 755ed95
- not used code removed
6od9i 7876390
- Trailing Whitespace fixed in tests
6od9i d76e6ee
fix: createNewAccount always non-hardened derivation
JeneaVranceanu a9ed5cd
Merge branch 'develop' into develop-6od9i
JeneaVranceanu b82e347
Merge pull request #2 from JeneaVranceanu/develop-6od9i
6od9i 216f11b
- bug with original pathAppendix fixed
6od9i a64e380
chore: refactoring of createNewCustomChildAccount
JeneaVranceanu 9c68d9b
- Test testAddressGeneration modified with hardcoded addresses
6od9i 886897c
chore: merged with develop
JeneaVranceanu 91975f6
fix: trimming / only if it's present as a prefix; using let for 'newP…
JeneaVranceanu ccae14f
Merge branch 'develop' of https://github.com/6od9i/web3swift into dev…
JeneaVranceanu 97def7b
fix: used short notation for null checking
JeneaVranceanu e806518
Merge pull request #3 from JeneaVranceanu/develop-6od9i
6od9i 752171b
chore: trailing closure style for compactMap
JeneaVranceanu dd32c16
- linter warning fixed
6od9i e587175
- isHardened check removed from createNewCustomChildAccount
6od9i File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// BIP32KeystoreTests.swift | ||
// localTests | ||
// | ||
// Created by 6od9i on 29.06.2023. | ||
// | ||
|
||
import Foundation | ||
import XCTest | ||
import Web3Core | ||
|
||
@testable import web3swift | ||
|
||
class BIP32KeystoreTests: XCTestCase { | ||
func testAddressGeneration() throws { | ||
/// Arrange | ||
/// Seed randomly generated for this test | ||
let mnemonic = "resource beyond merit enemy foot piece reveal eagle nothing luggage goose spot" | ||
let password = "test_password" | ||
|
||
let addressesCount: UInt = 101 | ||
|
||
guard let keystore = try BIP32Keystore( | ||
mnemonics: mnemonic, | ||
password: password, | ||
mnemonicsPassword: "", | ||
language: .english, | ||
prefixPath: HDNode.defaultPathMetamaskPrefix) else { | ||
XCTFail("Keystore has not generated") | ||
throw NSError(domain: "0", code: 0) | ||
} | ||
|
||
/// Act | ||
let addresses = try keystore.getAddressForAccount(password: password, | ||
number: addressesCount) | ||
|
||
guard let sameKeystore = try BIP32Keystore( | ||
mnemonics: mnemonic, | ||
password: password, | ||
mnemonicsPassword: "", | ||
language: .english, | ||
prefixPath: HDNode.defaultPathMetamaskPrefix) else { | ||
XCTFail("Keystore has not generated") | ||
throw NSError(domain: "0", code: 0) | ||
} | ||
|
||
let walletNumber = addressesCount - 1 | ||
try sameKeystore.createNewCustomChildAccount(password: password, | ||
path: HDNode.defaultPathMetamaskPrefix + "/\(walletNumber)") | ||
let address = sameKeystore.addresses?.last?.address | ||
|
||
/// Assert | ||
XCTAssertEqual(UInt(addresses.count), addressesCount) | ||
XCTAssertNotEqual(addresses[11], addresses[1]) | ||
XCTAssertEqual(addresses.last?.address, address) | ||
XCTAssertEqual("0xEF22ebb8Bb5CDa4EaCc98b280c94Cbaa3828566F", addresses.last?.address) | ||
XCTAssertEqual("0xdc69CBFE39c46B104875DF9602dFdCDB9b862a16", addresses.first?.address) | ||
XCTAssertEqual("0xdc69CBFE39c46B104875DF9602dFdCDB9b862a16", sameKeystore.addresses?.first?.address) | ||
XCTAssertEqual("0x971CF293b46162CD03DD9Cc39E89B592988DD6C4", addresses[Int(addressesCount / 2)].address) | ||
XCTAssertEqual("0x3B565482a93CE4adA9dE0fD3c118bd41E24CC23C", addresses[10].address) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.