Apply Operations types#97
Conversation
There was a problem hiding this comment.
Many of the operations in this class can be more specific. ExchangeOperation, KelOperation etc
There was a problem hiding this comment.
changed MultisigUtils for specifying op types
| opResponse1 = (HashMap<String, Object>) op1.getResponse(); | ||
| EventResult rpyResult1 = client1.identifiers().addEndRole( | ||
| var icpResult1 = client1.identifiers().create("alice", kargs1); | ||
| Operation op1 = waitOperation(client1, icpResult1.op()); |
There was a problem hiding this comment.
Can we use waitOperation with CompletedWitnessOperation.class? (same in other places in the tests)
There was a problem hiding this comment.
Or perhaps we need a waitForCompleted an throw an error if it's the error variant
There was a problem hiding this comment.
what do you think about this:
public static <T extends Operation> T waitForCompleted(
SignifyClient client,
Operation op,
Class<T> completedType
) throws Exception {
Operation result = waitOperation(client, op);
if (completedType.isInstance(result)) {
return completedType.cast(result);
}
if (result.getClass().getSimpleName().startsWith("Failed")) {
throw new IllegalStateException("Operation failed: " + result);
}
throw new IllegalStateException("Unexpected operation result type: " + result.getClass());
}
}
then using it
CompletedWitnessOperation op = waitForCompleted(client2, icpResult2.op(), CompletedWitnessOperation.class);
aid2Prefix = op.getResponse().getI();
There was a problem hiding this comment.
Perhaps waitForCompleted(client2, icpResult.op(), WitnessOperation.class
So it'll always be a WitnessOperation, but we throw an error if it's not a Completed* version
There was a problem hiding this comment.
In your example, you could have FailedCredentialOperation and would get the operation failed instead of unexpected operation result exception
No description provided.