feat: improve application access and money precision
This commit is contained in:
@@ -307,9 +307,9 @@ func TestReceiptWithoutOriginalSequenceIsUnrecoverable(t *testing.T) {
|
||||
defer resetDownstreamRegistry()
|
||||
|
||||
result, err := PushReceiptWithResult(DownstreamReceipt{
|
||||
DeliveryID: "delivery-history",
|
||||
Account: "100001",
|
||||
MessageID: "MSG-HISTORY",
|
||||
DeliveryID: "delivery-history",
|
||||
Account: "100001",
|
||||
MessageID: "MSG-HISTORY",
|
||||
ReceiptStatus: "undelivered",
|
||||
})
|
||||
if err != nil {
|
||||
@@ -325,11 +325,11 @@ func TestRecoverableReceiptWaitsForClientConnection(t *testing.T) {
|
||||
defer resetDownstreamRegistry()
|
||||
|
||||
result, err := PushReceiptWithResult(DownstreamReceipt{
|
||||
DeliveryID: "delivery-retry",
|
||||
Account: "100001",
|
||||
MessageID: "MSG-RETRY",
|
||||
DeliveryID: "delivery-retry",
|
||||
Account: "100001",
|
||||
MessageID: "MSG-RETRY",
|
||||
SubmitSequenceID: 77,
|
||||
ReceiptStatus: "delivered",
|
||||
ReceiptStatus: "delivered",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("push receipt: %v", err)
|
||||
@@ -659,7 +659,9 @@ func TestRememberAndForgetAccountUpdatesPresenceStore(t *testing.T) {
|
||||
instanceID: "gateway-a",
|
||||
}
|
||||
|
||||
rememberAccount(session)
|
||||
if !rememberAccount(&session, 1) {
|
||||
t.Fatal("expected account session to be accepted")
|
||||
}
|
||||
snapshot, ok := store.snapshots["100001"]
|
||||
if !ok {
|
||||
t.Fatal("expected presence snapshot to be stored")
|
||||
@@ -674,6 +676,25 @@ func TestRememberAndForgetAccountUpdatesPresenceStore(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRememberAccountEnforcesConfiguredConnectionLimit(t *testing.T) {
|
||||
resetDownstreamRegistry()
|
||||
defer resetDownstreamRegistry()
|
||||
|
||||
first := &downstreamSession{account: "100001", connectionID: "conn-1", conn: &cmpp.Conn{}, mu: &sync.Mutex{}}
|
||||
second := &downstreamSession{account: "100001", connectionID: "conn-2", conn: &cmpp.Conn{}, mu: &sync.Mutex{}}
|
||||
third := &downstreamSession{account: "100001", connectionID: "conn-3", conn: &cmpp.Conn{}, mu: &sync.Mutex{}}
|
||||
if !rememberAccount(first, 2) || !rememberAccount(second, 2) {
|
||||
t.Fatal("expected first two sessions to fit maxConnections=2")
|
||||
}
|
||||
if rememberAccount(third, 2) {
|
||||
t.Fatal("expected third session to be rejected by maxConnections=2")
|
||||
}
|
||||
forgetDownstream(first)
|
||||
if !rememberAccount(third, 2) {
|
||||
t.Fatal("expected a new session after a previous connection is released")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownstreamDeliveryRequiresAcknowledgement(t *testing.T) {
|
||||
resetDownstreamRegistry()
|
||||
defer resetDownstreamRegistry()
|
||||
@@ -702,9 +723,12 @@ func TestReceiptLookupDoesNotFallbackToAccountBeforeSubmitMappingExists(t *testi
|
||||
defer resetDownstreamRegistry()
|
||||
|
||||
conn := &cmpp.Conn{}
|
||||
rememberAccount(downstreamSession{
|
||||
session := &downstreamSession{
|
||||
account: "100001", protocol: "cmpp20", conn: conn, mu: &sync.Mutex{}, connectionID: "conn-1",
|
||||
})
|
||||
}
|
||||
if !rememberAccount(session, 1) {
|
||||
t.Fatal("expected account session to be accepted")
|
||||
}
|
||||
if session := findReceiptSession("MSG-NOT-REMEMBERED", "100001"); session != nil {
|
||||
t.Fatalf("receipt unexpectedly fell back to account session: %+v", session)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user