Skip to content

Commit

Permalink
Merge pull request #464 from mysteriumnetwork/experiment-promise-check
Browse files Browse the repository at this point in the history
Added --experiment-promise-check flag
  • Loading branch information
soffokl committed Oct 18, 2018
2 parents 993b5fc + 3873612 commit 32ebb4f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/di.go
Expand Up @@ -188,7 +188,10 @@ func (di *Dependencies) BootstrapServiceComponents(nodeOptions node.Options, ser
di.IdentityRegistry,
openvpnServiceManager,
func(proposal dto_discovery.ServiceProposal, configProvider session.ConfigProvider) communication.DialogHandler {
promiseHandler := func(dialog communication.Dialog) *noop.PromiseProcessor {
promiseHandler := func(dialog communication.Dialog) session.PromiseProcessor {
if nodeOptions.ExperimentPromiseCheck {
return &noop.FakePromiseEngine{}
}
return noop.NewPromiseProcessor(dialog, balance, di.Storage)
}
sessionManagerFactory := newSessionManagerFactory(proposal, configProvider, sessionStorage, promiseHandler)
Expand All @@ -202,7 +205,7 @@ func newSessionManagerFactory(
proposal dto_discovery.ServiceProposal,
configProvider session.ConfigProvider,
sessionStorage *session.StorageMemory,
promiseHandler func(dialog communication.Dialog) *noop.PromiseProcessor,
promiseHandler func(dialog communication.Dialog) session.PromiseProcessor,
) session.ManagerFactory {
return func(dialog communication.Dialog) session.Manager {
return session.NewManager(
Expand Down
7 changes: 7 additions & 0 deletions cmd/flags_network.go
Expand Up @@ -38,6 +38,11 @@ var (
Usage: "Enables experimental identity check",
}

promiseCheckFlag = cli.BoolFlag{
Name: "experiment-promise-check",
Usage: "Enables experimental promises check",
}

discoveryAddressFlag = cli.StringFlag{
Name: "discovery-address",
Usage: "Address (URL form) of discovery service",
Expand Down Expand Up @@ -73,6 +78,7 @@ func RegisterFlagsNetwork(flags *[]cli.Flag) {
*flags,
testFlag, localnetFlag,
identityCheckFlag,
promiseCheckFlag,
discoveryAddressFlag, brokerAddressFlag,
etherRpcFlag, etherContractPaymentsFlag,
qualityOracleFlag,
Expand All @@ -86,6 +92,7 @@ func ParseFlagsNetwork(ctx *cli.Context) node.OptionsNetwork {
ctx.GlobalBool(localnetFlag.Name),

ctx.GlobalBool(identityCheckFlag.Name),
ctx.GlobalBool(promiseCheckFlag.Name),

ctx.GlobalString(discoveryAddressFlag.Name),
ctx.GlobalString(brokerAddressFlag.Name),
Expand Down
3 changes: 3 additions & 0 deletions core/node/node.go
Expand Up @@ -57,6 +57,9 @@ func NewNode(
}

promiseIssuerFactory := func(issuerID identity.Identity, dialog communication.Dialog) connection.PromiseIssuer {
if options.ExperimentPromiseCheck {
return &noop.FakePromiseEngine{}
}
return noop.NewPromiseIssuer(issuerID, dialog, signerFactory(issuerID))
}

Expand Down
1 change: 1 addition & 0 deletions core/node/options_network.go
Expand Up @@ -23,6 +23,7 @@ type OptionsNetwork struct {
Localnet bool

ExperimentIdentityCheck bool
ExperimentPromiseCheck bool

DiscoveryAPIAddress string
BrokerAddress string
Expand Down
34 changes: 34 additions & 0 deletions core/promise/methods/noop/promise_processor_fake.go
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2018 The "MysteriumNetwork/node" Authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package noop

import discovery_dto "github.com/mysteriumnetwork/node/service_discovery/dto"

// FakePromiseEngine do nothing. It required for the temporary --experiment-promise-check flag.
// TODO it should be removed once --experiment-promise-check will be deleted.
type FakePromiseEngine struct{}

// Start fakes promise engine start
func (*FakePromiseEngine) Start(_ discovery_dto.ServiceProposal) error {
return nil
}

// Stop fakes promise engine stop
func (*FakePromiseEngine) Stop() error {
return nil
}
2 changes: 2 additions & 0 deletions e2e/docker-compose.yml
Expand Up @@ -20,6 +20,7 @@ services:
--ipify-url=http://ipify:3000
--location.country=e2e-land
--experiment-identity-check
--experiment-promise-check
--localnet
--broker-address=broker
--discovery-address=http://discovery/v1
Expand All @@ -45,6 +46,7 @@ services:
command: >
--ipify-url=http://ipify:3000
--experiment-identity-check
--experiment-promise-check
--localnet
--discovery-address=http://discovery/v1
--ether.client.rpc=http://geth:8545
Expand Down

0 comments on commit 32ebb4f

Please sign in to comment.