github.com/annchain/OG@v0.0.9/og/verifier/consensus_verifier_test.go (about) 1 package verifier 2 3 import ( 4 "fmt" 5 "github.com/annchain/OG/arefactor/og_interface" 6 "github.com/sirupsen/logrus" 7 "testing" 8 ) 9 10 func TestConsensusVerifier_Verify(t *testing.T) { 11 logrus.SetLevel(logrus.TraceLevel) 12 tx := archive.RandomTx() 13 //fmt.Println(tx) 14 pub, priv := og_interface.Signer.RandomKeyPair() 15 tx.From = nil 16 fmt.Println(tx.SignatureTargets()) 17 tx.Signature = og_interface.Signer.Sign(priv, tx.SignatureTargets()).SignatureBytes 18 tx.SetHash(tx.CalcTxHash()) 19 tx.From = nil 20 //fmt.Println(tx,"hehe") 21 v := verifier.TxFormatVerifier{NoVerifyMindHash: true, NoVerifyMaxTxHash: true} 22 ok := v.Verify(tx) 23 fmt.Println(tx, "hihi") 24 if !ok { 25 t.Fatal(ok) 26 } 27 if *tx.From != pub.Address() { 28 t.Fatal(tx.From, pub.Address()) 29 } 30 fmt.Println(tx.From, pub.Address()) 31 32 }