github.com/annchain/OG@v0.0.9/consensus/dkg/archive/dkg_partner_test.go (about)

     1  //// Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
     2  ////
     3  //// Licensed under the Apache License, Version 2.0 (the "License");
     4  //// you may not use this file except in compliance with the License.
     5  //// You may obtain a copy of the License at
     6  ////
     7  ////     http://www.apache.org/licenses/LICENSE-2.0
     8  ////
     9  //// Unless required by applicable law or agreed to in writing, software
    10  //// distributed under the License is distributed on an "AS IS" BASIS,
    11  //// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  //// See the License for the specific language governing permissions and
    13  //// limitations under the License.
    14  package archive
    15  //
    16  //import (
    17  //	"fmt"
    18  //	"github.com/annchain/OG/account"
    19  //	"github.com/annchain/OG/common"
    20  //	"github.com/annchain/OG/common/ogcrypto"
    21  //	"github.com/annchain/OG/common/hexutil"
    22  //	"github.com/annchain/OG/consensus/dkg"
    23  //	"github.com/annchain/OG/consensus/term"
    24  //	"github.com/annchain/OG/types/tx_types"
    25  //	"github.com/sirupsen/logrus"
    26  //	"testing"
    27  //)
    28  //
    29  //func TestDkg_VerifyBlsSig(t *testing.T) {
    30  //	seq := tx_types.RandomSequencer()
    31  //	fmt.Println(seq.GetHash().Hex())
    32  //	seq.PublicKey = []byte{}
    33  //}
    34  //
    35  //func logInit() {
    36  //	Formatter := new(logrus.TextFormatter)
    37  //	Formatter.TimestampFormat = "15:04:05.000000"
    38  //	Formatter.FullTimestamp = true
    39  //	logrus.SetFormatter(Formatter)
    40  //	logrus.SetLevel(logrus.TraceLevel)
    41  //	//filenameHook := filename.NewHook()
    42  //	//filenameHook.Field = "line"
    43  //	//logrus.AddHook(filenameHook)
    44  //	dkg.log = logrus.StandardLogger()
    45  //}
    46  //func TestVrfSelections_Le(t *testing.T) {
    47  //	logInit()
    48  //
    49  //	d := NewDkgPartner(true, 4, 3, nil, nil, nil)
    50  //	tm := term.NewTerm(1, 21, 4)
    51  //	d.term = tm
    52  //	for i := 0; i < 21; i++ {
    53  //		addr := common.RandomAddress()
    54  //		h := common.RandomHash()
    55  //		cp := tx_types.Campaign{
    56  //			Vrf: tx_types.VrfInfo{
    57  //				Vrf: h.KeyBytes[:],
    58  //			},
    59  //			Issuer: &addr,
    60  //		}
    61  //		tm.AddCampaign(&cp)
    62  //	}
    63  //	seq := &tx_types.Sequencer{
    64  //		Signature: common.RandomAddress().ToBytes(),
    65  //	}
    66  //	d.myAccount = getRandomAccount()
    67  //	d.SelectCandidates(seq)
    68  //	return
    69  //}
    70  //
    71  //func getRandomAccount() *account.Account {
    72  //	_, priv := ogcrypto.Signer.RandomKeyPair()
    73  //	return account.NewAccount(priv.String())
    74  //}
    75  //
    76  //func TestDKgLog(t *testing.T) {
    77  //	logInit()
    78  //	d := NewDkgPartner(true, 4, 3, nil, nil, nil)
    79  //	log := dkg.log.WithField("me", d.GetId())
    80  //	log.Debug("hi")
    81  //	d.context.MyIndex = 10
    82  //	log.Info("hi hi")
    83  //}
    84  //
    85  //func TestReset(t *testing.T) {
    86  //	logInit()
    87  //	d := NewDkgPartner(true, 4, 3, nil, nil, nil)
    88  //	dkg.log.Debug("sk ", d.context.MyPartSec)
    89  //	d.Reset(nil)
    90  //	dkg.log.Debug("sk ", d.context.MyPartSec)
    91  //	d.GenerateDkg()
    92  //	dkg.log.Debug("sk ", d.context.MyPartSec)
    93  //	d.Reset(nil)
    94  //	dkg.log.Debug("sk ", d.context.MyPartSec)
    95  //
    96  //}
    97  //
    98  //func TestNewDKGPartner(t *testing.T) {
    99  //
   100  //	for j := 0; j < 22; j++ {
   101  //		fmt.Println(j, j*2/3+1)
   102  //	}
   103  //	for i := 0; i < 4; i++ {
   104  //		d := NewDkgPartner(true, 4, 3, nil, nil, nil)
   105  //		fmt.Println(hexutil.Encode(d.PublicKey()))
   106  //		fmt.Println(d.context.MyPartSec)
   107  //	}
   108  //
   109  //}