Reduces non-deterministic failures of the refreshTTL tests that resulted
from the uncontrollable System.currentTimeMillis().
Now, all tests have extremely fine control over the elapsed time between
calls which makes the current and future tests much better.
Switch from System.currentTimeMills() to
Clock.millis() so dependency injection can
be used for tests that need finer control of time.
This involves attaching a Clock to the resolver
so all fromProto methods have one available when they
reconstruct a message. This uses the Injector for the APP
and a default Clock.systemDefaultZone is used in the manual
instantiations.
Work was already done in #3037 to make this possible.
All tests still use the default system clock for now.
Use the DI Clock object already available in P2PDataStore, instead
of calling System.currentTimeMillis() directly. These two functions
have the same behavior and switching over allows finer control
of time in the tests.
Remove operations are now only processed if the sequence number
is greater than the last operation seen for a specific payload.
The only creator of new remove entrys is the P2PService layer that always increments
the sequence number. So, this is either left around from a time where
removes needed to work with non-incrementing sequence numbers or just
a longstanding bug.
With the completion of this patch, all operations now require increasing
sequence numbers so it should be easier to reason about the behavior in
future debugging.
Now returns false if the sequence number of the refresh matches
the last operation seen for the specified hash. This is a more expected
return value when no state change occurs.
The only callers are either P2PService users that always increment the
sequence number or the onMessage() handler which doesn't verify the return
so there will be no visible change other than the increased readability
of the code and deduplication of the code paths.
Now returns false on duplicate sequence numbers. This matches more of
the expected behavior for an add() function when the element previously exists.
The only callers are either P2PService users that always increment the
sequence number or the onMessage() handler which doesn't verify the return
so there will be no visible change other than the increased readability
of the code and deduplication of the code paths.
Removed duplicate log messages that are handled inside the various helper methods
and print more verbose state useful for debugging.
Updated potentially misleading comments around hashing collisions
Fix a bug where remove() was called in the addMailboxData()
failure path.
1. Sender's can't remove mailbox entries. Only
the receiver can remove it so even if the previous add() failed and
left partial state, the remove() can never succeed.
2. Even if the sender could remove, this path used remove() instead
of removeMailboxData() so it wouldn't have succeed anyway.
This patch cleans up the failure path as well as adds a precondition
for the remove() function to ensure future callers don't use them for
ProtectedMailboxStorageEntrys.
* [TESTS] Add tests for P2PDataStorage in order to safely refactor
These tests create real versions of the supported Payload & Entry types and
run them through the 3 entry points (onMessage, Init, standard add()/remove()/refresh(),
to verify the expected return values, internal state changes, and
external signals (listeners, broadcasts).
The tests are involved and I am proposing future work to make many of the objects
more testable that will greatly reduce the work and tests cases needed.
This work identified a few unexpected scenarios and potential bugs that are addressed
in dependent pull requests.
Code coverage when running P2PDataStorageTest:
Before:
Line: 4%
Branch: 0%
After:
Line: 78%
Branch 76%
* [PR COMMENTS] Don't use the real Alert class
Instead, create a ProtectedStoragePayloadStub class which mocks out the required
protobuf Message for hashing. The hash is equal to the ownerPubKey so they are unique.
* [PR COMMENTS] Use Client API in comments
Change the use of "public api" to "Client API" to describe the set of
callers that use the pattern addProtectedStorageEntry(getProtectedStorageEntry())
as a contrast to the onMessage handler users or the GetData users.
* Improve handling of failed trades and offers
- Check if deposit tx is null
- Check if trade fee tx is rejected
- Listen to reject tx errors
- Cleanup addressEntryList
- Prevent opening disputes with if deposit tx is null
- Add null checks
- Improve logs
- Cleanups
* Add move to failed trade button to popup
In case the deposit tx is null we show a popup telling the user to move
the trade to failed trades after a restart if the problem persist.
* Change log level
Change the use of "public api" to "Client API" to describe the set of
callers that use the pattern addProtectedStorageEntry(getProtectedStorageEntry())
as a contrast to the onMessage handler users or the GetData users.
* Limit max. nr. of PersistableNetworkPayload and ProtectedStorageEntry to 10000
To avoid that seed nodes get overloaded with requests for too many
PersistableNetworkPayload and ProtectedStorageEntry data we limit nr. of
entries to max 10000.
* Add peers node address to logs
* Improve logs
- Add log of size to GetBlocksResponse.toProtoNetworkEnvelope method
- Log in kb
* Log connection UID if not peer address available
* Add cleanup code or invalid objects
We have an invalid Filter object in the live network (prob. some dev
made some mistake). This code helps so clean that up.
* Add log
Instead, create a ProtectedStoragePayloadStub class which mocks out the required
protobuf Message for hashing. The hash is equal to the ownerPubKey so they are unique.
These tests create real versions of the supported Payload & Entry types and
run them through the 3 entry points (onMessage, Init, standard add()/remove()/refresh(),
to verify the expected return values, internal state changes, and
external signals (listeners, broadcasts).
The tests are involved and I am proposing future work to make many of the objects
more testable that will greatly reduce the work and tests cases needed.
This work identified a few unexpected scenarios and potential bugs that are addressed
in dependent pull requests.
Code coverage when running P2PDataStorageTest:
Before:
Line: 4%
Branch: 0%
After:
Line: 78%
Branch 76%
When hovering over the BTC balances, the popup was using the market
price based on the locale combined with the preferred currency as its
units. This lead to the situation where it could show a mismatch
between value and units.
Instead, use the market price based on the preferred currency.
Fixes#3515