-
Notifications
You must be signed in to change notification settings - Fork 20
feat(ledger): Add friendly string representation of TX outputs #1174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
33aed59
feat(ledger): Added friendly string representation of TX outputs for …
arepala-uml be52da6
feat(ledger): Modifed Check part in all the tests for the exact expec…
arepala-uml 33ee0d8
feat(ledger): Ensured original address string is preserved in output …
arepala-uml 57ff156
feat(ledger): Replace fmt.Sprintf with with assets=+assets to fix the…
arepala-uml File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,6 +649,21 @@ func (o BabbageTransactionOutput) Utxorpc() (*utxorpc.TxOutput, error) { | |
nil | ||
} | ||
|
||
func (o BabbageTransactionOutput) String() string { | ||
assets := "" | ||
if o.OutputAmount.Assets != nil { | ||
if as := o.OutputAmount.Assets.String(); as != "[]" { | ||
assets = " assets=" + as | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should build out a list of the assets for the string output |
||
return fmt.Sprintf( | ||
"(BabbageTransactionOutput address=%s amount=%d%s)", | ||
o.OutputAddress.String(), | ||
o.OutputAmount.Amount, | ||
assets, | ||
) | ||
} | ||
|
||
type BabbageTransactionWitnessSet struct { | ||
cbor.DecodeStoreCbor | ||
VkeyWitnesses []common.VkeyWitness `cbor:"0,keyasint,omitempty"` | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package shelley_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/blinklabs-io/gouroboros/ledger/common" | ||
"github.com/blinklabs-io/gouroboros/ledger/shelley" | ||
) | ||
|
||
func TestShelleyTransactionOutputString(t *testing.T) { | ||
addrStr := "addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd" | ||
addr, _ := common.NewAddress(addrStr) | ||
out := shelley.ShelleyTransactionOutput{ | ||
OutputAddress: addr, | ||
OutputAmount: 456, | ||
} | ||
s := out.String() | ||
expected := fmt.Sprintf("(ShelleyTransactionOutput address=%s amount=456)", addrStr) | ||
if s != expected { | ||
t.Fatalf("unexpected string: %s", s) | ||
} | ||
agaffney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func TestShelleyOutputTooSmallErrorFormatting(t *testing.T) { | ||
addrStr := "addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd" | ||
addr, _ := common.NewAddress(addrStr) | ||
out := &shelley.ShelleyTransactionOutput{ | ||
OutputAddress: addr, | ||
OutputAmount: 456, | ||
} | ||
errStr := shelley.OutputTooSmallUtxoError{Outputs: []common.TransactionOutput{out}}.Error() | ||
expected := fmt.Sprintf("output too small: (ShelleyTransactionOutput address=%s amount=456)", addrStr) | ||
if errStr != expected { | ||
t.Fatalf("unexpected error: %s", errStr) | ||
} | ||
agaffney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.