forked from livepeer/go-livepeer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request livepeer#1291 from livepeer/nv/o-active-check2
cmd, core, eth/watchers: O checks that it is active in ProcessPayment
- Loading branch information
Showing
11 changed files
with
500 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"math/big" | ||
"testing" | ||
|
||
ethcommon "github.com/ethereum/go-ethereum/common" | ||
"github.com/livepeer/go-livepeer/common" | ||
"github.com/livepeer/go-livepeer/core" | ||
"github.com/livepeer/go-livepeer/eth" | ||
lpTypes "github.com/livepeer/go-livepeer/eth/types" | ||
"github.com/livepeer/go-livepeer/pm" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSetupOrchestrator(t *testing.T) { | ||
require := require.New(t) | ||
assert := assert.New(t) | ||
|
||
dbh, dbraw, err := common.TempDB(t) | ||
require.Nil(err) | ||
|
||
defer dbh.Close() | ||
defer dbraw.Close() | ||
|
||
orch := pm.RandAddress() | ||
|
||
stubEthClient := ð.StubClient{ | ||
Orch: &lpTypes.Transcoder{ | ||
Address: orch, | ||
ActivationRound: big.NewInt(5), | ||
DeactivationRound: big.NewInt(10), | ||
}, | ||
TranscoderAddress: orch, | ||
} | ||
|
||
n, err := core.NewLivepeerNode(stubEthClient, "", dbh) | ||
require.Nil(err) | ||
|
||
err = setupOrchestrator(context.Background(), n, false) | ||
assert.Nil(err) | ||
|
||
orchs, err := dbh.SelectOrchs(&common.DBOrchFilter{ | ||
Addresses: []ethcommon.Address{orch}, | ||
}) | ||
assert.Nil(err) | ||
assert.Len(orchs, 1) | ||
assert.Equal(orchs[0].ActivationRound, int64(5)) | ||
assert.Equal(orchs[0].DeactivationRound, int64(10)) | ||
|
||
// test eth.GetTranscoder error | ||
stubEthClient.Err = errors.New("GetTranscoder error") | ||
err = setupOrchestrator(context.Background(), n, false) | ||
assert.EqualError(err, "GetTranscoder error") | ||
} |
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
Oops, something went wrong.