Skip to content

Commit

Permalink
Implement GetAddresses for TxStakeCompound type (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeimonDB authored May 30, 2022
1 parent 304be10 commit a7d8b52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (t *Tx) GetAddresses() []string {
return append(addresses, t.From, t.To)
case TxSwap:
return append(addresses, t.From, t.To)
case TxStakeDelegate, TxStakeRedelegate, TxStakeUndelegate, TxStakeClaimRewards:
case TxStakeDelegate, TxStakeRedelegate, TxStakeUndelegate, TxStakeClaimRewards, TxStakeCompound:
return append(addresses, t.From)
default:
return addresses
Expand Down
23 changes: 23 additions & 0 deletions types/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ func TestTx_GetAddresses(t *testing.T) {
},
expected: []string{"from_utxo", "to_utxo"},
},
{
name: "stake_compound",
tx: Tx{
Type: TxStakeCompound,
From: "from",
To: "to",
Metadata: &Transfer{},
},
expected: []string{"from"},
},
}

for _, tc := range tests {
Expand All @@ -238,6 +248,19 @@ func TestTx_GetAddresses(t *testing.T) {
})
}

// make sure all supported types have a test
supportedTypesMap := map[TransactionType]struct{}{}
for _, supportedType := range SupportedTypes {
supportedTypesMap[supportedType] = struct{}{}
}

testedTypesMap := map[TransactionType]struct{}{}
for _, tc := range tests {
if _, supported := supportedTypesMap[tc.tx.Type]; supported {
testedTypesMap[tc.tx.Type] = struct{}{}
}
}
assert.Equal(t, len(supportedTypesMap), len(testedTypesMap))
}

func TestTx_GetDirection(t *testing.T) {
Expand Down

0 comments on commit a7d8b52

Please sign in to comment.