Skip to content
Snippets Groups Projects
Select Git revision
  • dfff4e78b1545296d2b63dd1fd12b13a1ecb948a
  • main default protected
  • development
  • integration
  • v1.1.5
  • v1.1.4
  • v1.1.3
  • v1.1.2
  • v1.1.1
  • v1.1.0
  • v1.0.0
11 results

CMixWaitForNetwork.swift

Blame
  • utils_test.go 719.64 KiB
    ///////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 xx network SEZC                                          //
    //                                                                           //
    // Use of this source code is governed by a license that can be found in the //
    // LICENSE file                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    
    package api
    
    import (
    	"bytes"
    	"testing"
    
    	"gitlab.com/elixxir/client/cmix/gateway"
    	"gitlab.com/elixxir/client/e2e"
    
    	"github.com/pkg/errors"
    	jww "github.com/spf13/jwalterweatherman"
    	pb "gitlab.com/elixxir/comms/mixmessages"
    	"gitlab.com/elixxir/comms/network"
    	"gitlab.com/elixxir/comms/testkeys"
    	"gitlab.com/xx_network/comms/connect"
    	"gitlab.com/xx_network/comms/signature"
    	"gitlab.com/xx_network/crypto/signature/rsa"
    	"gitlab.com/xx_network/crypto/tls"
    	"gitlab.com/xx_network/primitives/id"
    	"gitlab.com/xx_network/primitives/ndf"
    	"gitlab.com/xx_network/primitives/utils"
    )
    
    func newTestingClient(face interface{}) (*Client, error) {
    	switch face.(type) {
    	case *testing.T, *testing.M, *testing.B, *testing.PB:
    		break
    	default:
    		jww.FATAL.Panicf("InitTestingSession is restricted to testing "+
    			"only. Got %T", face)
    	}
    
    	def := getNDF(face)
    	marshalledDef, _ := def.Marshal()
    	storageDir := "ignore.1"
    	password := []byte("hunter2")
    	err := NewClient(string(marshalledDef), storageDir, password, "AAAA")
    	if err != nil {
    		return nil, errors.Errorf(
    			"Could not construct a mock client: %v", err)
    	}
    
    	c, err := OpenClient(storageDir, password, e2e.GetDefaultParams())
    	if err != nil {
    		return nil, errors.Errorf("Could not open a mock client: %v",
    			err)
    	}
    
    	commsManager := connect.NewManagerTesting(face)
    
    	cert, err := utils.ReadFile(testkeys.GetNodeCertPath())
    	if err != nil {
    		jww.FATAL.Panicf("Failed to create new test instance: %v", err)
    	}
    
    	commsManager.AddHost(&id.Permissioning, "", cert,
    		connect.GetDefaultHostParams())
    	instanceComms := &connect.ProtoComms{
    		Manager: commsManager,
    	}
    
    	thisInstance, err := network.NewInstanceTesting(instanceComms, def,
    		def, nil, nil, face)