-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into disable-array-parameters
- Loading branch information
Showing
8 changed files
with
345 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 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 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
94 changes: 94 additions & 0 deletions
94
cmd/soroban-rpc/internal/methods/simulate_transaction_test.go
This file contains 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,94 @@ | ||
package methods | ||
|
||
import ( | ||
"encoding/base64" | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stellar/go/xdr" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/preflight" | ||
) | ||
|
||
func TestLedgerEntryChange(t *testing.T) { | ||
entry := xdr.LedgerEntry{ | ||
LastModifiedLedgerSeq: 100, | ||
Data: xdr.LedgerEntryData{ | ||
Type: xdr.LedgerEntryTypeAccount, | ||
Account: &xdr.AccountEntry{ | ||
AccountId: xdr.MustAddress("GBXGQJWVLWOYHFLVTKWV5FGHA3LNYY2JQKM7OAJAUEQFU6LPCSEFVXON"), | ||
Balance: 100, | ||
SeqNum: 1, | ||
}, | ||
}, | ||
} | ||
|
||
entryXDR, err := entry.MarshalBinary() | ||
require.NoError(t, err) | ||
entryB64 := base64.StdEncoding.EncodeToString(entryXDR) | ||
|
||
key, err := entry.LedgerKey() | ||
require.NoError(t, err) | ||
keyXDR, err := key.MarshalBinary() | ||
require.NoError(t, err) | ||
keyB64 := base64.StdEncoding.EncodeToString(keyXDR) | ||
|
||
for _, test := range []struct { | ||
name string | ||
input preflight.XDRDiff | ||
expectedOutput LedgerEntryChange | ||
}{ | ||
{ | ||
name: "creation", | ||
input: preflight.XDRDiff{ | ||
Before: nil, | ||
After: entryXDR, | ||
}, | ||
expectedOutput: LedgerEntryChange{ | ||
Type: LedgerEntryChangeTypeCreated, | ||
Key: keyB64, | ||
Before: nil, | ||
After: &entryB64, | ||
}, | ||
}, | ||
{ | ||
name: "deletion", | ||
input: preflight.XDRDiff{ | ||
Before: entryXDR, | ||
After: nil, | ||
}, | ||
expectedOutput: LedgerEntryChange{ | ||
Type: LedgerEntryChangeTypeDeleted, | ||
Key: keyB64, | ||
Before: &entryB64, | ||
After: nil, | ||
}, | ||
}, | ||
{ | ||
name: "update", | ||
input: preflight.XDRDiff{ | ||
Before: entryXDR, | ||
After: entryXDR, | ||
}, | ||
expectedOutput: LedgerEntryChange{ | ||
Type: LedgerEntryChangeTypeUpdated, | ||
Key: keyB64, | ||
Before: &entryB64, | ||
After: &entryB64, | ||
}, | ||
}, | ||
} { | ||
var change LedgerEntryChange | ||
require.NoError(t, change.FromXDRDiff(test.input), test.name) | ||
assert.Equal(t, test.expectedOutput, change) | ||
|
||
// test json roundtrip | ||
changeJSON, err := json.Marshal(change) | ||
require.NoError(t, err, test.name) | ||
var change2 LedgerEntryChange | ||
require.NoError(t, json.Unmarshal(changeJSON, &change2)) | ||
assert.Equal(t, change, change2, test.name) | ||
} | ||
} |
This file contains 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 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 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
Oops, something went wrong.