mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-18 19:25:48 +00:00
* create credentials obj, modify depositpreauth * structrure of transaction models * initial validation methods and modify transactions affected by deposit auth * cleanup and add new transactions to list * binarycodec and add amendments to config * methods account for credentials * binary codec update * add amendments to config * error validation for credentials actions * core logic of error validation completed * type checking in error validation * init test files and field type validations * basic tests for crud transactions * cred delete tests * cred accept unit tests * cred create and accept unit tests * cred delete unit tests * depositPreauth unit tests * generic checks for payment, paymentchannelclaim, escrowfinish credential list * ledger entry update * lint errors * cleanup and use helper methods * fix lint bug * init integration tests for new transactions * fix build error, integration test docker update * unit test fixes -- all pass now * integration test layout complete * integration command * integration tests run * cicd command edit * lint and cleanup * modified history markdown * deposit preauth integration update * update docs with new docker command * fix validation for string id credential arrays * exports * add flag * lint * fix typo in contributing doc * docstring typos * readable string * fix test' * review comment fixes * txn duplicate fix * Apply suggestions from code review Co-authored-by: Omar Khan <khancodegt@gmail.com> Co-authored-by: Mayukha Vadari <mvadari@ripple.com> * Apply suggestions from code review Co-authored-by: Omar Khan <khancodegt@gmail.com> * Apply suggestions from code review Co-authored-by: Omar Khan <khancodegt@gmail.com> Co-authored-by: Mayukha Vadari <mvadari@ripple.com> * typo in auto suggest * rebase * readd definitions after rebase * cleanup list val * unit tests fixed and running * lint * refactor authcred check to work * Update packages/xrpl/src/models/transactions/payment.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * typo * Update .ci-config/rippled.cfg Co-authored-by: Omar Khan <khancodegt@gmail.com> * update rippled version * optional field nits * add to response depositauthorize * Update packages/xrpl/src/models/transactions/CredentialCreate.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * Update packages/xrpl/src/models/transactions/CredentialDelete.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * Update packages/xrpl/src/models/transactions/accountDelete.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * Apply suggestions from code review Co-authored-by: Omar Khan <khancodegt@gmail.com> * cleanups * unit test fix * more escrowfinish tests * clearer error message * re add statement * undo autodeleted mandates * remove extraneous integration tests for now * lint * Update .ci-config/rippled.cfg Co-authored-by: Omar Khan <khancodegt@gmail.com> * Update packages/xrpl/src/models/transactions/common.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * added tests * typo --------- Co-authored-by: Omar Khan <khancodegt@gmail.com> Co-authored-by: Mayukha Vadari <mvadari@ripple.com>
106 lines
3.3 KiB
TypeScript
106 lines
3.3 KiB
TypeScript
import { stringToHex } from '@xrplf/isomorphic/utils'
|
|
import { assert } from 'chai'
|
|
|
|
import {
|
|
AccountObjectsResponse,
|
|
CredentialAccept,
|
|
CredentialCreate,
|
|
} from '../../../src'
|
|
import { CredentialDelete } from '../../../src/models/transactions/CredentialDelete'
|
|
import serverUrl from '../serverUrl'
|
|
import {
|
|
setupClient,
|
|
teardownClient,
|
|
type XrplIntegrationTestContext,
|
|
} from '../setup'
|
|
import { generateFundedWallet, testTransaction } from '../utils'
|
|
|
|
describe('CredentialDelete', function () {
|
|
// testContext wallet acts as issuer in this test
|
|
let testContext: XrplIntegrationTestContext
|
|
|
|
beforeAll(async () => {
|
|
testContext = await setupClient(serverUrl)
|
|
})
|
|
afterAll(async () => teardownClient(testContext))
|
|
|
|
it('base', async function () {
|
|
const subjectWallet = await generateFundedWallet(testContext.client)
|
|
|
|
const credentialCreateTx: CredentialCreate = {
|
|
TransactionType: 'CredentialCreate',
|
|
Account: testContext.wallet.classicAddress,
|
|
Subject: subjectWallet.classicAddress,
|
|
CredentialType: stringToHex('Test Credential Type'),
|
|
}
|
|
|
|
await testTransaction(
|
|
testContext.client,
|
|
credentialCreateTx,
|
|
testContext.wallet,
|
|
)
|
|
|
|
const createAccountObjectsResponse: AccountObjectsResponse =
|
|
await testContext.client.request({
|
|
command: 'account_objects',
|
|
account: testContext.wallet.classicAddress,
|
|
type: 'credential',
|
|
})
|
|
|
|
assert.equal(createAccountObjectsResponse.result.account_objects.length, 1)
|
|
|
|
const credentialAcceptTx: CredentialAccept = {
|
|
TransactionType: 'CredentialAccept',
|
|
Account: subjectWallet.classicAddress,
|
|
Issuer: testContext.wallet.classicAddress,
|
|
CredentialType: stringToHex('Test Credential Type'),
|
|
}
|
|
|
|
await testTransaction(testContext.client, credentialAcceptTx, subjectWallet)
|
|
|
|
// Credential is now an object in recipient's wallet after accept
|
|
const acceptAccountObjectsResponse: AccountObjectsResponse =
|
|
await testContext.client.request({
|
|
command: 'account_objects',
|
|
account: subjectWallet.classicAddress,
|
|
type: 'credential',
|
|
})
|
|
|
|
assert.equal(acceptAccountObjectsResponse.result.account_objects.length, 1)
|
|
|
|
const credentialDeleteTx: CredentialDelete = {
|
|
TransactionType: 'CredentialDelete',
|
|
Account: subjectWallet.classicAddress,
|
|
Issuer: testContext.wallet.classicAddress,
|
|
CredentialType: stringToHex('Test Credential Type'),
|
|
}
|
|
|
|
await testTransaction(testContext.client, credentialDeleteTx, subjectWallet)
|
|
|
|
// Check both issuer and subject no longer have a credential tied to the account
|
|
const SubjectAccountObjectsDeleteResponse: AccountObjectsResponse =
|
|
await testContext.client.request({
|
|
command: 'account_objects',
|
|
account: subjectWallet.classicAddress,
|
|
type: 'credential',
|
|
})
|
|
|
|
assert.equal(
|
|
SubjectAccountObjectsDeleteResponse.result.account_objects.length,
|
|
0,
|
|
)
|
|
|
|
const IssuerAccountObjectsDeleteResponse: AccountObjectsResponse =
|
|
await testContext.client.request({
|
|
command: 'account_objects',
|
|
account: testContext.wallet.classicAddress,
|
|
type: 'credential',
|
|
})
|
|
|
|
assert.equal(
|
|
IssuerAccountObjectsDeleteResponse.result.account_objects.length,
|
|
0,
|
|
)
|
|
})
|
|
})
|