-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Impl IsActiveForConsensusView, provided by the oracle * Impl ContextualBlocks getter for tortoise * Fixed memdb
- Loading branch information
Showing
24 changed files
with
672 additions
and
123 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,27 +1,36 @@ | ||
package eligibility | ||
|
||
import ( | ||
"github.com/spacemeshos/go-spacemesh/config" | ||
"github.com/spacemeshos/go-spacemesh/types" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
type mockPatternProvider struct { | ||
val uint32 | ||
err error | ||
val uint32 | ||
valGenesis uint32 | ||
err error | ||
} | ||
|
||
func (mpp *mockPatternProvider) GetGoodPattern(layer types.LayerID) (uint32, error) { | ||
if layer == config.Genesis { | ||
return mpp.valGenesis, mpp.err | ||
} | ||
return mpp.val, mpp.err | ||
} | ||
|
||
func TestBeacon_Value(t *testing.T) { | ||
b := beacon{} | ||
b.patternProvider = &mockPatternProvider{1, someErr} | ||
_, err := b.Value(5) | ||
b.patternProvider = &mockPatternProvider{1, 5, someErr} | ||
b.confidenceParam = cfg.ConfidenceParam | ||
_, err := b.Value(100) | ||
assert.NotNil(t, err) | ||
b.patternProvider = &mockPatternProvider{3, nil} | ||
val, err := b.Value(5) | ||
b.patternProvider = &mockPatternProvider{3, 5, nil} | ||
val, err := b.Value(100) | ||
assert.Nil(t, err) | ||
assert.Equal(t, uint32(3), val) | ||
val, err = b.Value(1) | ||
assert.Nil(t, err) | ||
assert.Equal(t, uint32(5), val) | ||
} |
This file contains 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,11 @@ | ||
package config | ||
|
||
type Config struct { | ||
ConfidenceParam uint64 `mapstructure:"eligibility-confidence-param"` // the confidence interval | ||
GenesisActiveSet int `mapstructure:"eligibility-genesis-active-size"` // the active set size for genesis | ||
EpochOffset int `mapstructure:"eligibility-epoch-offset"` // the offset from the beginning of the epoch | ||
} | ||
|
||
func DefaultConfig() Config { | ||
return Config{25, 5, 30} | ||
} |
Oops, something went wrong.