Compare commits

..

4 Commits

2 changed files with 1 additions and 38 deletions

View File

@ -78,9 +78,6 @@ func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol,
for i, sym := range symList {
parts := strings.SplitN(sym, ":", 2)
if len(parts) != 2 {
continue
}
if input == parts[0] || strings.EqualFold(input, 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),
}
// 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
for key, value := range activeEntries {
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
}

View File

@ -32,11 +32,6 @@ func InitializeTestDb(t *testing.T) (context.Context, *common.UserDataStore) {
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) {
symbols := "1:SRF\n2:MILO"
balances := "1:100\n2:200"
@ -206,18 +201,4 @@ func TestUpdateVoucherData(t *testing.T) {
require.NoError(t, err)
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)
}
}