Skip to content

Commit

Permalink
Fix ClientFor/Previewnet/Testnet/Mainnet with correct LedgerID
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuel Pargov <[email protected]>
  • Loading branch information
bamzedev committed Nov 15, 2022
1 parent fb0ca7b commit 86585a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ func ClientForNetwork(network map[string]AccountID) *Client {
// Most users will want to set an _Operator account with .SetOperator so
// transactions can be automatically given TransactionIDs and signed.
func ClientForMainnet() *Client {
return _NewClient(*_NetworkForTestnet(mainnetNodes._ToMap()), mainnetMirror, NetworkNameMainnet)
return _NewClient(*_NetworkForMainnet(mainnetNodes._ToMap()), mainnetMirror, NetworkNameMainnet)
}

// ClientForTestnet returns a preconfigured client for use with the standard
// Hedera testnet.
// Most users will want to set an _Operator account with .SetOperator so
// transactions can be automatically given TransactionIDs and signed.
func ClientForTestnet() *Client {
return _NewClient(*_NetworkForPreviewnet(testnetNodes._ToMap()), testnetMirror, NetworkNameTestnet)
return _NewClient(*_NetworkForTestnet(testnetNodes._ToMap()), testnetMirror, NetworkNameTestnet)
}

// ClientForPreviewnet returns a preconfigured client for use with the standard
// Hedera previewnet.
// Most users will want to set an _Operator account with .SetOperator so
// transactions can be automatically given TransactionIDs and signed.
func ClientForPreviewnet() *Client {
return _NewClient(*_NetworkForMainnet(previewnetNodes._ToMap()), previewnetMirror, NetworkNamePreviewnet)
return _NewClient(*_NetworkForPreviewnet(previewnetNodes._ToMap()), previewnetMirror, NetworkNamePreviewnet)
}

// newClient takes in a map of _Node addresses to their respective IDS (_Network)
Expand All @@ -140,7 +140,7 @@ func _NewClient(network _Network, mirrorNetwork []string, name NetworkName) *Cli

// We can't ask for AddressBook from non existent Mirror node
if len(mirrorNetwork) > 0 {
// Update the Addressbook, before the deafult timeout starts
// Update the Addressbook, before the default timeout starts
client._UpdateAddressBook()
go client._ScheduleNetworkUpdate(ctx, client.defaultNetworkUpdatePeriod)
}
Expand Down
4 changes: 2 additions & 2 deletions client_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestUnitClientFromConfig(t *testing.T) {
require.NoError(t, err)

assert.NotNil(t, client)
assert.Equal(t, 10, len(client.network.network))
assert.Equal(t, 7, len(client.network.network))
assert.Nil(t, client.operator)
}

Expand All @@ -49,7 +49,7 @@ func TestUnitClientFromConfigWithOperator(t *testing.T) {
testOperatorKey, err := PrivateKeyFromString("302e020100300506032b657004220420db484b828e64b2d8f12ce3c0a0e93a0b8cce7af1bb8f39c97732394482538e10")
require.NoError(t, err)

assert.Equal(t, 10, len(client.network.network))
assert.Equal(t, 7, len(client.network.network))
assert.NotNil(t, client.operator)
assert.Equal(t, testOperatorKey.ed25519PrivateKey.keyData, client.operator.privateKey.ed25519PrivateKey.keyData)
assert.Equal(t, AccountID{Account: 3}.Account, client.operator.accountID.Account)
Expand Down
1 change: 0 additions & 1 deletion managed_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (this *_ManagedNetwork) _SetNetwork(network map[string]_IManagedNode) error
this.nodes = newNodes
this.network = newNetwork
this.healthyNodes = newHealthyNodes
this.ledgerID = nil

return nil
}
Expand Down

0 comments on commit 86585a0

Please sign in to comment.