Skip to content

Commit

Permalink
Merge branch 'main' into 1066-add-missing-methods-to-TopicMessageSubm…
Browse files Browse the repository at this point in the history
…itTransaction
  • Loading branch information
gsstoykov authored Sep 25, 2024
2 parents 81220cf + 4f6172e commit 5977204
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 138 deletions.
25 changes: 25 additions & 0 deletions account_balance_query_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package hedera
*/

import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -212,3 +213,27 @@ func TestIntegrationAccountBalanceQueryWorksWithHollowAccountAlias(t *testing.T)
err = CloseIntegrationTestEnv(env, nil)
require.NoError(t, err)
}

func TestIntegrationAccountBalanceQueryCanConnectToMainnetTls(t *testing.T) {
t.Parallel()
client := ClientForMainnet()
client.SetTransportSecurity(true)

succeededOnce := false
for address, accountID := range client.GetNetwork() {

if !strings.HasSuffix(address, ":50212") {
t.Errorf("Expected entry key to end with ':50212', but got %s", address)
}

accountIDs := []AccountID{accountID}
_, err := NewAccountBalanceQuery().
SetNodeAccountIDs(accountIDs).
SetAccountID(accountID).
Execute(client)
if err == nil {
succeededOnce = true
}
}
assert.True(t, succeededOnce)
}
17 changes: 11 additions & 6 deletions endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ import (
)

type Endpoint struct {
address IPv4Address
address []byte
port int32
domainName string
}

func (endpoint *Endpoint) SetAddress(address IPv4Address) *Endpoint {
func (endpoint *Endpoint) SetAddress(address []byte) *Endpoint {
endpoint.address = address
return endpoint
}

func (endpoint *Endpoint) GetAddress() IPv4Address {
func (endpoint *Endpoint) GetAddress() []byte {
return endpoint.address
}

Expand Down Expand Up @@ -67,15 +67,15 @@ func EndpointFromProtobuf(serviceEndpoint *services.ServiceEndpoint) Endpoint {
}

return Endpoint{
address: Ipv4AddressFromProtobuf(serviceEndpoint.GetIpAddressV4()),
address: serviceEndpoint.GetIpAddressV4(),
port: port,
domainName: serviceEndpoint.GetDomainName(),
}
}

func (endpoint *Endpoint) _ToProtobuf() *services.ServiceEndpoint {
return &services.ServiceEndpoint{
IpAddressV4: endpoint.address._ToProtobuf(),
IpAddressV4: endpoint.address,
Port: endpoint.port,
DomainName: endpoint.domainName,
}
Expand All @@ -86,6 +86,11 @@ func (endpoint *Endpoint) String() string {
// If domain name is populated domainName + port
return endpoint.domainName + ":" + fmt.Sprintf("%d", endpoint.port)
} else {
return endpoint.address.String() + ":" + fmt.Sprintf("%d", endpoint.port)
return fmt.Sprintf("%d.%d.%d.%d:%d",
int(endpoint.address[0])&0xFF,
int(endpoint.address[1])&0xFF,
int(endpoint.address[2])&0xFF,
int(endpoint.address[3])&0xFF,
endpoint.port)
}
}
3 changes: 1 addition & 2 deletions examples/dab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ func main() {
description := "Hedera™ cryptocurrency"
newDescription := "Hedera™ cryptocurrency - updated"

ipv4 := hedera.IPv4Address{}
ipv4.SetNetwork(0, 0).SetHost(0, 0)
ipv4 := []byte{127, 0, 0, 1}

gossipEndpoint := hedera.Endpoint{}
gossipEndpoint.SetAddress(ipv4).SetPort(50211)
Expand Down
67 changes: 0 additions & 67 deletions ipv4_address.go

This file was deleted.

52 changes: 0 additions & 52 deletions ipv4_address_part.go

This file was deleted.

11 changes: 1 addition & 10 deletions node_create_transaction_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,7 @@ func endpoints(offsets ...uint) []Endpoint {

for _, offset := range offsets {
endpoints = append(endpoints, Endpoint{
address: IPv4Address{
network: IPv4AddressPart{
left: byte(offset),
right: byte(offset),
},
host: IPv4AddressPart{
left: byte(offset),
right: byte(offset),
},
},
address: []byte{byte(offset), byte(offset), byte(offset), byte(offset)},
})
}

Expand Down
2 changes: 1 addition & 1 deletion query.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (q *Query) SetPaymentTransactionID(transactionID TransactionID) *Query {

func (q *Query) execute(client *Client, e QueryInterface) (*services.Response, error) {
q.client = client
if client == nil || client.operator == nil {
if client == nil {
return nil, errNoClientProvided
}

Expand Down

0 comments on commit 5977204

Please sign in to comment.