lash/export-to-term #157

Merged
lash merged 92 commits from lash/export-to-term into master 2024-11-04 13:54:59 +01:00
2 changed files with 1 additions and 38 deletions
Showing only changes of commit 33bba73a65 - Show all commits

View File

@ -78,9 +78,6 @@ func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol,
for i, sym := range symList { for i, sym := range symList {
parts := strings.SplitN(sym, ":", 2) parts := strings.SplitN(sym, ":", 2)
if len(parts) != 2 {
continue
}
if input == parts[0] || strings.EqualFold(input, parts[1]) { if input == parts[0] || strings.EqualFold(input, parts[1]) {
symbol = parts[1] symbol = parts[1]
@ -154,14 +151,6 @@ func UpdateVoucherData(ctx context.Context, store common.DataStore, sessionId st
common.DATA_ACTIVE_ADDRESS: []byte(data.ContractAddress), common.DATA_ACTIVE_ADDRESS: []byte(data.ContractAddress),
} }
// Clear temporary voucher data entries
tempEntries := map[common.DataTyp][]byte{
common.DATA_TEMPORARY_SYM: []byte(""),
common.DATA_TEMPORARY_BAL: []byte(""),
common.DATA_TEMPORARY_DECIMAL: []byte(""),
common.DATA_TEMPORARY_ADDRESS: []byte(""),
}
// Write active data // Write active data
for key, value := range activeEntries { for key, value := range activeEntries {
if err := store.WriteEntry(ctx, sessionId, key, value); err != nil { if err := store.WriteEntry(ctx, sessionId, key, value); err != nil {
@ -169,12 +158,5 @@ func UpdateVoucherData(ctx context.Context, store common.DataStore, sessionId st
} }
} }
// Clear temporary data
for key, value := range tempEntries {
if err := store.WriteEntry(ctx, sessionId, key, value); err != nil {
return err
}
}
return nil return nil
} }

View File

@ -32,11 +32,6 @@ func InitializeTestDb(t *testing.T) (context.Context, *common.UserDataStore) {
return ctx, store return ctx, store
} }
// AssertEmptyValue checks if a value is empty/nil/zero
func AssertEmptyValue(t *testing.T, value []byte, msgAndArgs ...interface{}) {
assert.Equal(t, len(value), 0, msgAndArgs...)
}
func TestMatchVoucher(t *testing.T) { func TestMatchVoucher(t *testing.T) {
symbols := "1:SRF\n2:MILO" symbols := "1:SRF\n2:MILO"
balances := "1:100\n2:200" balances := "1:100\n2:200"
@ -206,18 +201,4 @@ func TestUpdateVoucherData(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, expectedValue, storedValue, "Active data mismatch for key %v", key) require.Equal(t, expectedValue, storedValue, "Active data mismatch for key %v", key)
} }
// Verify temporary data was cleared
tempKeys := []common.DataTyp{
common.DATA_TEMPORARY_SYM,
common.DATA_TEMPORARY_BAL,
common.DATA_TEMPORARY_DECIMAL,
common.DATA_TEMPORARY_ADDRESS,
}
for _, key := range tempKeys {
storedValue, err := store.ReadEntry(ctx, sessionId, key)
require.NoError(t, err)
AssertEmptyValue(t, storedValue, "Temporary data not cleared for key %v", key)
}
} }