MCPcopy Create free account
hub / github.com/CPChain/chain / verify

Method verify

tests/transaction_test_util.go:98–132  ·  view source on GitHub ↗
(signer types.Signer, tx *types.Transaction)

Source from the content-addressed store, hash-verified

96}
97
98func (tt *ttTransaction) verify(signer types.Signer, tx *types.Transaction) error {
99 if !bytes.Equal(tx.Data(), tt.Data) {
100 return fmt.Errorf("Tx input data mismatch: got %x want %x", tx.Data(), tt.Data)
101 }
102 if tx.Gas() != tt.GasLimit {
103 return fmt.Errorf("GasLimit mismatch: got %d, want %d", tx.Gas(), tt.GasLimit)
104 }
105 if tx.GasPrice().Cmp(tt.GasPrice) != 0 {
106 return fmt.Errorf("GasPrice mismatch: got %v, want %v", tx.GasPrice(), tt.GasPrice)
107 }
108 if tx.Nonce() != tt.Nonce {
109 return fmt.Errorf("Nonce mismatch: got %v, want %v", tx.Nonce(), tt.Nonce)
110 }
111 v, r, s := tx.RawSignatureValues()
112 if r.Cmp(tt.R) != 0 {
113 return fmt.Errorf("R mismatch: got %v, want %v", r, tt.R)
114 }
115 if s.Cmp(tt.S) != 0 {
116 return fmt.Errorf("S mismatch: got %v, want %v", s, tt.S)
117 }
118 if v.Cmp(tt.V) != 0 {
119 return fmt.Errorf("V mismatch: got %v, want %v", v, tt.V)
120 }
121 if tx.To() == nil {
122 if tt.To != (common.Address{}) {
123 return fmt.Errorf("To mismatch when recipient is nil (contract creation): %x", tt.To)
124 }
125 } else if *tx.To() != tt.To {
126 return fmt.Errorf("To mismatch: got %x, want %x", *tx.To(), tt.To)
127 }
128 if tx.Value().Cmp(tt.Value) != 0 {
129 return fmt.Errorf("Value mismatch: got %x, want %x", tx.Value(), tt.Value)
130 }
131 return nil
132}

Callers 1

RunMethod · 0.80

Calls 9

CmpMethod · 0.80
EqualMethod · 0.65
DataMethod · 0.65
GasMethod · 0.65
GasPriceMethod · 0.65
NonceMethod · 0.65
ToMethod · 0.65
ValueMethod · 0.65
RawSignatureValuesMethod · 0.45

Tested by

no test coverage detected