Skip to content

Commit 272db8b

Browse files
committed
test: add pending airdrop record unit test
Signed-off-by: Aditya Arya <arya050411@gmail.com>
1 parent f44385e commit 272db8b

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//go:build all || unit
2+
3+
package hiero
4+
5+
// SPDX-License-Identifier: Apache-2.0
6+
7+
import (
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/require"
12+
)
13+
14+
func TestUnitPendingAirdropRecordProtoRoundTrip(t *testing.T) {
15+
t.Parallel()
16+
17+
accID, err := AccountIDFromString("0.0.123")
18+
require.NoError(t, err)
19+
tokenID, err := TokenIDFromString("0.0.456")
20+
require.NoError(t, err)
21+
22+
original := PendingAirdropRecord{
23+
pendingAirdropId: PendingAirdropId{&accID, &accID, &tokenID, nil},
24+
pendingAirdropAmount: 789,
25+
}
26+
27+
roundTripped := _PendingAirdropRecordFromProtobuf(original._ToProtobuf())
28+
29+
assert.Equal(t, original, roundTripped)
30+
assert.Equal(t, uint64(789), roundTripped.GetPendingAirdropAmount())
31+
assert.Equal(t, original.GetPendingAirdropId(), roundTripped.GetPendingAirdropId())
32+
}
33+
34+
func TestUnitPendingAirdropRecordString(t *testing.T) {
35+
t.Parallel()
36+
37+
accID, err := AccountIDFromString("0.0.123")
38+
require.NoError(t, err)
39+
tokenID, err := TokenIDFromString("0.0.456")
40+
require.NoError(t, err)
41+
42+
record := PendingAirdropRecord{
43+
pendingAirdropId: PendingAirdropId{&accID, &accID, &tokenID, nil},
44+
pendingAirdropAmount: 789,
45+
}
46+
47+
expected := "PendingAirdropRecord{PendingAirdropId: Sender: 0.0.123, Receiver: 0.0.123, TokenID: 0.0.456, NftID: nil, PendingAirdropAmount: 789}"
48+
assert.Equal(t, expected, record.String())
49+
}

0 commit comments

Comments
 (0)