mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
[BUGFIX] Fix off-by-one in truncation logic
Now, the truncation is only triggered if more than MAX_ENTRIES could have been returned.
This commit is contained in:
parent
e7673407f1
commit
00128d912d
@ -248,7 +248,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||||||
objToPayload.apply(networkPayload)))
|
objToPayload.apply(networkPayload)))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
if (limit.get() <= 0)
|
if (limit.get() < 0)
|
||||||
outTruncated.set(true);
|
outTruncated.set(true);
|
||||||
|
|
||||||
return filteredResults;
|
return filteredResults;
|
||||||
|
@ -189,7 +189,6 @@ public class P2PDataStorageBuildGetDataResponseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TESTCASE: Given a GetDataRequest w/o known PNP, send it back
|
// TESTCASE: Given a GetDataRequest w/o known PNP, send it back
|
||||||
// XXXBUGXXX: Truncation return has off-by-one error
|
|
||||||
@Test
|
@Test
|
||||||
public void buildGetDataResponse_unknownPNPSendBack() {
|
public void buildGetDataResponse_unknownPNPSendBack() {
|
||||||
PersistableNetworkPayload onlyLocal = new PersistableNetworkPayloadStub(new byte[]{1});
|
PersistableNetworkPayload onlyLocal = new PersistableNetworkPayloadStub(new byte[]{1});
|
||||||
@ -204,7 +203,7 @@ public class P2PDataStorageBuildGetDataResponseTest {
|
|||||||
AtomicBoolean outPSETruncated = new AtomicBoolean(false);
|
AtomicBoolean outPSETruncated = new AtomicBoolean(false);
|
||||||
Capabilities peerCapabilities = new Capabilities();
|
Capabilities peerCapabilities = new Capabilities();
|
||||||
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
|
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
|
||||||
getDataRequest, 2, outPNPTruncated, outPSETruncated, peerCapabilities);
|
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
|
||||||
|
|
||||||
Assert.assertFalse(outPNPTruncated.get());
|
Assert.assertFalse(outPNPTruncated.get());
|
||||||
Assert.assertFalse(outPSETruncated.get());
|
Assert.assertFalse(outPSETruncated.get());
|
||||||
@ -355,7 +354,6 @@ public class P2PDataStorageBuildGetDataResponseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TESTCASE: Given a GetDataRequest w/o known PSE, send it back
|
// TESTCASE: Given a GetDataRequest w/o known PSE, send it back
|
||||||
// XXXBUGXXX: Truncation return has off-by-one error
|
|
||||||
@Test
|
@Test
|
||||||
public void buildGetDataResponse_unknownPSESendBack() throws NoSuchAlgorithmException {
|
public void buildGetDataResponse_unknownPSESendBack() throws NoSuchAlgorithmException {
|
||||||
ProtectedStorageEntry onlyLocal = getProtectedStorageEntryForAdd();
|
ProtectedStorageEntry onlyLocal = getProtectedStorageEntryForAdd();
|
||||||
@ -369,7 +367,7 @@ public class P2PDataStorageBuildGetDataResponseTest {
|
|||||||
AtomicBoolean outPSETruncated = new AtomicBoolean(false);
|
AtomicBoolean outPSETruncated = new AtomicBoolean(false);
|
||||||
Capabilities peerCapabilities = new Capabilities();
|
Capabilities peerCapabilities = new Capabilities();
|
||||||
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
|
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
|
||||||
getDataRequest, 2, outPNPTruncated, outPSETruncated, peerCapabilities);
|
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
|
||||||
|
|
||||||
Assert.assertFalse(outPNPTruncated.get());
|
Assert.assertFalse(outPNPTruncated.get());
|
||||||
Assert.assertFalse(outPSETruncated.get());
|
Assert.assertFalse(outPSETruncated.get());
|
||||||
|
Loading…
Reference in New Issue
Block a user