Skip to content

Commit

Permalink
Merge pull request #80 from ElrondNetwork/rc/2022-july
Browse files Browse the repository at this point in the history
`rc/2022 july`
  • Loading branch information
iulianpascalau authored Sep 23, 2022
2 parents 891011f + 3cd1931 commit 3abc884
Show file tree
Hide file tree
Showing 21 changed files with 712 additions and 472 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: [ main, development, feat/* ]
branches: [ main, development, feat/*, rc/* ]
pull_request:
branches: [ main, development, feat/* ]
branches: [ main, development, feat/*, rc/* ]

jobs:
test:
Expand Down
3 changes: 3 additions & 0 deletions core/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ var ErrNilLogger = errors.New("nil logger")

// ErrNilGoRoutineProcessor signals that a nil go routine processor has been provided
var ErrNilGoRoutineProcessor = errors.New("nil go routine processor")

// ErrNilPubkeyConverter signals that a nil public key converter has been provided
var ErrNilPubkeyConverter = errors.New("nil pubkey converter")
13 changes: 13 additions & 0 deletions core/optionals.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core

// OptionalUint32 holds an optional uint32 value
type OptionalUint32 struct {
Value uint32
HasValue bool
}

// OptionalUint64 holds an optional uint64 value
type OptionalUint64 struct {
Value uint64
HasValue bool
}
6 changes: 6 additions & 0 deletions core/peerID.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import "github.com/mr-tron/base58/base58"
// PeerID is a p2p peer identity.
type PeerID string

// NewPeerID creates a new peer id or returns an error
func NewPeerID(input string) (PeerID, error) {
pidBytes, err := base58.Decode(input)
return PeerID(pidBytes), err
}

// Bytes returns the peer ID as byte slice
func (pid PeerID) Bytes() []byte {
return []byte(pid)
Expand Down
28 changes: 28 additions & 0 deletions core/peerID_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package core

import (
"bytes"
"testing"

"github.com/stretchr/testify/assert"
)

func TestNewPeerID(t *testing.T) {
t.Parallel()
t.Run("invalid string should error", func(t *testing.T) {
t.Parallel()

providedStr := "provided str"
_, err := NewPeerID(providedStr)
assert.NotNil(t, err)
})
t.Run("should work", func(t *testing.T) {
t.Parallel()

providedStr := "provided str"
providedPeerID := PeerID(providedStr)
pid, err := NewPeerID(providedPeerID.Pretty())
assert.Nil(t, err)
assert.True(t, bytes.Equal([]byte(providedPeerID), pid.Bytes()))
})
}
182 changes: 0 additions & 182 deletions core/peersholder/peersHolder.go

This file was deleted.

Loading

0 comments on commit 3abc884

Please sign in to comment.