Skip to content
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

Add wrappers to easily convert between ScVal and native types. #630

Merged
merged 22 commits into from
Jun 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add nested structure tests
  • Loading branch information
Shaptic committed Jun 22, 2023
commit 2f94ba4effe81108d7e06162ff058272094f4e86
19 changes: 18 additions & 1 deletion test/unit/smart_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,24 @@ describe('parsing and building ScVals', function () {
new StellarBase.Address(kp.publicKey()).toScVal(),
(actual) => actual.toString() === kp.publicKey()
],
[xdr.ScVal.scvVec(inputVec.map(xdr.ScVal.scvString)), inputVec]
[xdr.ScVal.scvVec(inputVec.map(xdr.ScVal.scvString)), inputVec],
[
xdr.ScVal.scvMap(
[
[new ScInt(0).toI256(), xdr.ScVal.scvBool(true)],
[xdr.ScVal.scvBool(false), xdr.ScVal.scvString('second')],
[
xdr.ScVal.scvU32(2),
xdr.ScVal.scvVec(inputVec.map(xdr.ScVal.scvString))
]
].map(([key, val]) => new xdr.ScMapEntry({ key, val }))
),
{
0: true,
false: 'second',
2: inputVec
}
]
].forEach(([scv, expected]) => {
expect(() => scv.toXDR(), 'ScVal is invalid').to.not.throw();

Expand Down