| 162 | } |
| 163 | |
| 164 | func TestGetHash(t *testing.T) { |
| 165 | // pre-define a test message |
| 166 | sig := &Signature{ |
| 167 | PublicKey: newTestPublicKeyBytes(t), |
| 168 | Signature: newTestPublicKeyBytes(t), |
| 169 | } |
| 170 | // pre-define an any for testing |
| 171 | a, e := NewAny(sig) |
| 172 | require.NoError(t, e) |
| 173 | // pre-define a transaction |
| 174 | tx := &Transaction{ |
| 175 | MessageType: testMessageName, |
| 176 | Msg: a, |
| 177 | Signature: sig, |
| 178 | Time: uint64(time.Now().UnixMicro()), |
| 179 | Fee: 1, |
| 180 | Memo: "memo", |
| 181 | } |
| 182 | // calculate expected |
| 183 | bz, err := Marshal(tx) |
| 184 | require.NoError(t, err) |
| 185 | expected := crypto.Hash(bz) |
| 186 | // execute function call |
| 187 | got, err := tx.GetHash() |
| 188 | require.NoError(t, err) |
| 189 | // compare got vs expected |
| 190 | require.Equal(t, expected, got) |
| 191 | } |
| 192 | |
| 193 | func TestGetSignBytes(t *testing.T) { |
| 194 | // pre-define a test message |