Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mock staterepo #73

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

HashEngineering
Copy link
Collaborator

Issue being fixed or feature implemented

What was done?

How Has This Been Tested?

Breaking Changes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Comment on lines +43 to +52
private fun compare(a: Any, b: Any?, operator: String): Boolean {
when (operator) {
"==" -> {
return when {
a is ByteArray && b is ByteArray -> a.contentEquals(b as? ByteArray)
a is Identifier && b is ByteArray -> a == Identifier.from(b)
a is ByteArray && b is Identifier -> Identifier.from(a) == b
else -> a == b
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to support some queries for DashPay.

Comment on lines +85 to +89
a is Int && b is Int -> b.toInt() > a.toInt()
a is Long && b is Long -> b.toLong() > a.toLong()
a is Int && b is Long -> b.toInt() > a.toLong()
a is Long && b is Int -> b.toLong() > a.toInt()
else -> throw throw UnsupportedOperationException("> has unknown operands: " + a.javaClass.name + " and " + b?.javaClass?.name)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this is over kill on the Ints and Longs

Comment on lines 150 to 151
private fun loadMockData() {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we add mock data. Data is in CBOR format and can be taken from the logs of DashPay.

Currently there are two usernames that are created with profiles in this data. And one ContactRequest.

Comment on lines 44 to 48
var stateRepository = if (mockDAPI()) {
MockPlatformStateRepository(this)
} else {
PlatformStateRepository(this)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is written in a way to easily turn off mocking the data.

Copy link
Member

@Syn-McJ Syn-McJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

@HashEngineering
Copy link
Collaborator Author

This won't be merged for now, but instead will become the base branch for the Mocked State Repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants