@audius/sdk 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +38 -0
- package/.prettierrc.js +1 -0
- package/.python-version +1 -0
- package/Dockerfile +15 -0
- package/README.md +3 -0
- package/babel.config.js +3 -0
- package/data-contracts/ABIs/AdminUpgradeabilityProxy.json +132 -0
- package/data-contracts/ABIs/BaseAdminUpgradeabilityProxy.json +113 -0
- package/data-contracts/ABIs/BaseUpgradeabilityProxy.json +22 -0
- package/data-contracts/ABIs/DiscoveryProviderFactory.json +189 -0
- package/data-contracts/ABIs/DiscoveryProviderFactoryInterface.json +61 -0
- package/data-contracts/ABIs/DiscoveryProviderStorage.json +205 -0
- package/data-contracts/ABIs/DiscoveryProviderStorageInterface.json +65 -0
- package/data-contracts/ABIs/ECDSA.json +4 -0
- package/data-contracts/ABIs/IPLDBlacklistFactory.json +168 -0
- package/data-contracts/ABIs/Initializable.json +4 -0
- package/data-contracts/ABIs/Migrations.json +67 -0
- package/data-contracts/ABIs/OpenZeppelinUpgradesAddress.json +4 -0
- package/data-contracts/ABIs/Ownable.json +79 -0
- package/data-contracts/ABIs/PlaylistFactory.json +669 -0
- package/data-contracts/ABIs/PlaylistFactoryInterface.json +42 -0
- package/data-contracts/ABIs/PlaylistStorage.json +250 -0
- package/data-contracts/ABIs/PlaylistStorageInterface.json +129 -0
- package/data-contracts/ABIs/Proxy.json +10 -0
- package/data-contracts/ABIs/Registry.json +240 -0
- package/data-contracts/ABIs/RegistryContract.json +102 -0
- package/data-contracts/ABIs/RegistryContractInterface.json +28 -0
- package/data-contracts/ABIs/RegistryInterface.json +66 -0
- package/data-contracts/ABIs/SigningLogic.json +43 -0
- package/data-contracts/ABIs/SigningLogicInitializable.json +46 -0
- package/data-contracts/ABIs/SocialFeatureFactory.json +460 -0
- package/data-contracts/ABIs/SocialFeatureStorage.json +225 -0
- package/data-contracts/ABIs/SocialFeatureStorageInterface.json +123 -0
- package/data-contracts/ABIs/TestContract.json +135 -0
- package/data-contracts/ABIs/TestContractInterface.json +19 -0
- package/data-contracts/ABIs/TestContractWithStorage.json +165 -0
- package/data-contracts/ABIs/TestContractWithStorageInterface.json +24 -0
- package/data-contracts/ABIs/TestStorage.json +144 -0
- package/data-contracts/ABIs/TestStorageInterface.json +42 -0
- package/data-contracts/ABIs/TestUserReplicaSetManager.json +432 -0
- package/data-contracts/ABIs/TrackFactory.json +391 -0
- package/data-contracts/ABIs/TrackFactoryInterface.json +73 -0
- package/data-contracts/ABIs/TrackStorage.json +223 -0
- package/data-contracts/ABIs/TrackStorageInterface.json +121 -0
- package/data-contracts/ABIs/UpgradeabilityProxy.json +37 -0
- package/data-contracts/ABIs/UserFactory.json +657 -0
- package/data-contracts/ABIs/UserFactoryInterface.json +65 -0
- package/data-contracts/ABIs/UserLibraryFactory.json +334 -0
- package/data-contracts/ABIs/UserReplicaSetManager.json +418 -0
- package/data-contracts/ABIs/UserStorage.json +233 -0
- package/data-contracts/ABIs/UserStorageInterface.json +93 -0
- package/data-contracts/signatureSchemas.ts +1236 -0
- package/dist/core.d.ts +446 -0
- package/dist/core.js +769 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +689 -0
- package/dist/index.js +72850 -0
- package/dist/index.js.map +1 -0
- package/eth-contracts/ABIs/Address.json +4 -0
- package/eth-contracts/ABIs/AudiusAdminUpgradeabilityProxy.json +105 -0
- package/eth-contracts/ABIs/AudiusClaimDistributor.json +4968 -0
- package/eth-contracts/ABIs/AudiusToken.json +724 -0
- package/eth-contracts/ABIs/BaseUpgradeabilityProxy.json +23 -0
- package/eth-contracts/ABIs/Checkpointing.json +4 -0
- package/eth-contracts/ABIs/ClaimsManager.json +539 -0
- package/eth-contracts/ABIs/Context.json +11 -0
- package/eth-contracts/ABIs/DelegateManager.json +989 -0
- package/eth-contracts/ABIs/DelegateManagerV2.json +1049 -0
- package/eth-contracts/ABIs/DelegateManagerV2Bad.json +1049 -0
- package/eth-contracts/ABIs/ERC20.json +252 -0
- package/eth-contracts/ABIs/ERC20Burnable.json +287 -0
- package/eth-contracts/ABIs/ERC20Detailed.json +270 -0
- package/eth-contracts/ABIs/ERC20Mintable.json +364 -0
- package/eth-contracts/ABIs/ERC20Pausable.json +397 -0
- package/eth-contracts/ABIs/EthRewardsManager.json +174 -0
- package/eth-contracts/ABIs/Governance.json +938 -0
- package/eth-contracts/ABIs/GovernanceUpgraded.json +953 -0
- package/eth-contracts/ABIs/GovernanceV2.json +938 -0
- package/eth-contracts/ABIs/IERC20.json +200 -0
- package/eth-contracts/ABIs/Initializable.json +4 -0
- package/eth-contracts/ABIs/InitializableV2.json +14 -0
- package/eth-contracts/ABIs/Migrations.json +71 -0
- package/eth-contracts/ABIs/MinterRole.json +91 -0
- package/eth-contracts/ABIs/MockAccount.json +62 -0
- package/eth-contracts/ABIs/MockDelegateManager.json +55 -0
- package/eth-contracts/ABIs/MockStakingCaller.json +259 -0
- package/eth-contracts/ABIs/MockWormhole.json +106 -0
- package/eth-contracts/ABIs/OpenZeppelinUpgradesAddress.json +4 -0
- package/eth-contracts/ABIs/Ownable.json +93 -0
- package/eth-contracts/ABIs/Pausable.json +150 -0
- package/eth-contracts/ABIs/PauserRole.json +91 -0
- package/eth-contracts/ABIs/Proxy.json +10 -0
- package/eth-contracts/ABIs/Registry.json +288 -0
- package/eth-contracts/ABIs/Roles.json +4 -0
- package/eth-contracts/ABIs/SafeERC20.json +4 -0
- package/eth-contracts/ABIs/SafeMath.json +4 -0
- package/eth-contracts/ABIs/ServiceProviderFactory.json +1153 -0
- package/eth-contracts/ABIs/ServiceTypeManager.json +337 -0
- package/eth-contracts/ABIs/Staking.json +555 -0
- package/eth-contracts/ABIs/StakingUpgraded.json +570 -0
- package/eth-contracts/ABIs/TestContract.json +44 -0
- package/eth-contracts/ABIs/TrustedNotifierManager.json +265 -0
- package/eth-contracts/ABIs/Uint256Helpers.json +4 -0
- package/eth-contracts/ABIs/UpgradeabilityProxy.json +40 -0
- package/eth-contracts/ABIs/Wormhole.json +45 -0
- package/eth-contracts/ABIs/WormholeClient.json +155 -0
- package/examples/file.mp3 +0 -0
- package/examples/initAudiusLibs.js +86 -0
- package/examples/initializeVersions.js +95 -0
- package/examples/pic.jpg +0 -0
- package/initScripts/configureLocalDiscProv.js +167 -0
- package/initScripts/helpers/claim.js +43 -0
- package/initScripts/helpers/distributeTokens.js +24 -0
- package/initScripts/helpers/spRegistration.js +138 -0
- package/initScripts/helpers/utils.js +34 -0
- package/initScripts/helpers/version.js +93 -0
- package/initScripts/local.js +617 -0
- package/initScripts/mainnet.js +131 -0
- package/initScripts/manageProdRelayerWallets.js +191 -0
- package/package.json +125 -0
- package/rollup.config.js +164 -0
- package/scripts/AudiusClaimDistributor.json +4968 -0
- package/scripts/Wormhole.json +155 -0
- package/scripts/addCIDToIpldBlacklist.js +124 -0
- package/scripts/circleci-test.sh +53 -0
- package/scripts/communityRewards/transferCommunityRewardsToSolana.js +222 -0
- package/scripts/ipfs.sh +58 -0
- package/scripts/migrate_contracts.sh +25 -0
- package/scripts/reset.sh +65 -0
- package/scripts/test.sh +77 -0
- package/src/api/account.js +670 -0
- package/src/api/base.js +122 -0
- package/src/api/file.js +168 -0
- package/src/api/playlist.js +328 -0
- package/src/api/rewards.d.ts +4 -0
- package/src/api/rewards.js +682 -0
- package/src/api/serviceProvider.js +154 -0
- package/src/api/track.js +604 -0
- package/src/api/user.js +888 -0
- package/src/api/user.test.js +172 -0
- package/src/constants.ts +7 -0
- package/src/core.ts +3 -0
- package/src/index.js +6 -0
- package/src/libs.d.ts +3 -0
- package/src/libs.js +619 -0
- package/src/sanityChecks/addSecondaries.js +40 -0
- package/src/sanityChecks/assignReplicaSetIfNecessary.js +10 -0
- package/src/sanityChecks/index.d.ts +9 -0
- package/src/sanityChecks/index.js +31 -0
- package/src/sanityChecks/isCreator.js +73 -0
- package/src/sanityChecks/needsRecoveryEmail.js +20 -0
- package/src/sanityChecks/rolloverNodes.js +74 -0
- package/src/sanityChecks/sanitizeNodes.js +24 -0
- package/src/sanityChecks/syncNodes.js +28 -0
- package/src/sdk/constants.ts +10 -0
- package/src/sdk/index.ts +1 -0
- package/src/sdk/oauth/Oauth.ts +265 -0
- package/src/sdk/oauth/index.ts +1 -0
- package/src/sdk/sdk.ts +102 -0
- package/src/service-selection/ServiceSelection.test.ts +320 -0
- package/src/service-selection/ServiceSelection.ts +460 -0
- package/src/service-selection/constants.ts +14 -0
- package/src/service-selection/index.ts +1 -0
- package/src/services/ABIDecoder/AudiusABIDecoder.ts +71 -0
- package/src/services/ABIDecoder/index.ts +1 -0
- package/src/services/comstock/Comstock.ts +39 -0
- package/src/services/comstock/index.ts +1 -0
- package/src/services/contracts/ContractClient.ts +227 -0
- package/src/services/contracts/GovernedContractClient.ts +53 -0
- package/src/services/contracts/ProviderSelection.ts +42 -0
- package/src/services/creatorNode/CreatorNode.ts +1065 -0
- package/src/services/creatorNode/CreatorNodeSelection.test.ts +997 -0
- package/src/services/creatorNode/CreatorNodeSelection.ts +488 -0
- package/src/services/creatorNode/constants.ts +10 -0
- package/src/services/creatorNode/index.ts +2 -0
- package/src/services/dataContracts/AudiusContracts.ts +234 -0
- package/src/services/dataContracts/IPLDBlacklistFactoryClient.ts +73 -0
- package/src/services/dataContracts/PlaylistFactoryClient.ts +370 -0
- package/src/services/dataContracts/RegistryClient.ts +95 -0
- package/src/services/dataContracts/SocialFeatureFactoryClient.ts +196 -0
- package/src/services/dataContracts/TrackFactoryClient.ts +131 -0
- package/src/services/dataContracts/UserFactoryClient.ts +351 -0
- package/src/services/dataContracts/UserLibraryFactoryClient.ts +115 -0
- package/src/services/dataContracts/UserReplicaSetManagerClient.ts +206 -0
- package/src/services/dataContracts/index.ts +1 -0
- package/src/services/discoveryProvider/DiscoveryProvider.ts +1168 -0
- package/src/services/discoveryProvider/DiscoveryProviderSelection.test.ts +536 -0
- package/src/services/discoveryProvider/DiscoveryProviderSelection.ts +383 -0
- package/src/services/discoveryProvider/constants.ts +13 -0
- package/src/services/discoveryProvider/index.ts +1 -0
- package/src/services/discoveryProvider/requests.ts +629 -0
- package/src/services/ethContracts/AudiusTokenClient.ts +163 -0
- package/src/services/ethContracts/ClaimDistributionClient.ts +45 -0
- package/src/services/ethContracts/ClaimsManagerClient.ts +102 -0
- package/src/services/ethContracts/DelegateManagerClient.ts +480 -0
- package/src/services/ethContracts/EthContracts.ts +359 -0
- package/src/services/ethContracts/EthRewardsManagerClient.ts +33 -0
- package/src/services/ethContracts/GovernanceClient.ts +451 -0
- package/src/services/ethContracts/RegistryClient.ts +33 -0
- package/src/services/ethContracts/ServiceProviderFactoryClient.ts +691 -0
- package/src/services/ethContracts/ServiceTypeManagerClient.ts +112 -0
- package/src/services/ethContracts/StakingProxyClient.ts +97 -0
- package/src/services/ethContracts/TrustedNotifierManagerClient.ts +101 -0
- package/src/services/ethContracts/WormholeClient.ts +97 -0
- package/src/services/ethContracts/index.ts +1 -0
- package/src/services/ethWeb3Manager/EthWeb3Manager.ts +239 -0
- package/src/services/ethWeb3Manager/index.ts +1 -0
- package/src/services/hedgehog/Hedgehog.ts +96 -0
- package/src/services/hedgehog/index.ts +1 -0
- package/src/services/identity/IdentityService.ts +551 -0
- package/src/services/identity/index.ts +1 -0
- package/src/services/identity/requests.ts +65 -0
- package/src/services/schemaValidator/SchemaValidator.ts +105 -0
- package/src/services/schemaValidator/index.ts +1 -0
- package/src/services/schemaValidator/schemas/trackSchema.json +267 -0
- package/src/services/schemaValidator/schemas/userSchema.json +230 -0
- package/src/services/solanaAudiusData/errors.ts +20 -0
- package/src/services/solanaAudiusData/index.ts +1189 -0
- package/src/services/solanaWeb3Manager/errors.js +101 -0
- package/src/services/solanaWeb3Manager/index.d.ts +46 -0
- package/src/services/solanaWeb3Manager/index.js +655 -0
- package/src/services/solanaWeb3Manager/padBNToUint8Array.ts +7 -0
- package/src/services/solanaWeb3Manager/rewards.js +941 -0
- package/src/services/solanaWeb3Manager/rewardsAttester.ts +1093 -0
- package/src/services/solanaWeb3Manager/tokenAccount.js +149 -0
- package/src/services/solanaWeb3Manager/transactionHandler.js +345 -0
- package/src/services/solanaWeb3Manager/transfer.js +272 -0
- package/src/services/solanaWeb3Manager/userBank.js +160 -0
- package/src/services/solanaWeb3Manager/utils.d.ts +31 -0
- package/src/services/solanaWeb3Manager/utils.js +163 -0
- package/src/services/solanaWeb3Manager/wAudio.js +28 -0
- package/src/services/solanaWeb3Manager/wAudio.test.js +30 -0
- package/src/services/web3Manager/Web3Config.ts +14 -0
- package/src/services/web3Manager/Web3Manager.ts +360 -0
- package/src/services/web3Manager/XMLHttpRequest.ts +11 -0
- package/src/services/web3Manager/index.ts +2 -0
- package/src/services/wormhole/index.js +424 -0
- package/src/types.ts +8 -0
- package/src/userStateManager.ts +53 -0
- package/src/utils/apiSigning.ts +51 -0
- package/src/utils/captcha.ts +97 -0
- package/src/utils/estimateGas.ts +64 -0
- package/src/utils/fileHasher.ts +278 -0
- package/src/utils/importContractABI.d.ts +9 -0
- package/src/utils/importContractABI.js +19 -0
- package/src/utils/index.ts +11 -0
- package/src/utils/multiProvider.ts +72 -0
- package/src/utils/network.test.ts +127 -0
- package/src/utils/network.ts +308 -0
- package/src/utils/promiseFight.test.ts +87 -0
- package/src/utils/promiseFight.ts +36 -0
- package/src/utils/signatures.ts +139 -0
- package/src/utils/types.ts +34 -0
- package/src/utils/utils.test.ts +36 -0
- package/src/utils/utils.ts +235 -0
- package/src/utils/uuid.ts +14 -0
- package/src/web3.d.ts +9 -0
- package/src/web3.js +8 -0
- package/tests/assets/static_image.png +0 -0
- package/tests/assets/static_text.txt +1 -0
- package/tests/audiusTokenClientTest.js +37 -0
- package/tests/creatorNodeTest.js +19 -0
- package/tests/fileHasherTest.js +125 -0
- package/tests/governanceTest.js +382 -0
- package/tests/helpers.js +105 -0
- package/tests/index.js +14 -0
- package/tests/playlistClientTest.js +157 -0
- package/tests/providerSelectionTest.js +241 -0
- package/tests/registryClientTest.js +19 -0
- package/tests/rewardsAttesterTest.js +373 -0
- package/tests/serviceTypeManagerClientTest.js +33 -0
- package/tests/socialFeatureClientTest.js +79 -0
- package/tests/stakingTest.js +302 -0
- package/tests/trackClientTest.js +86 -0
- package/tests/userClientTest.js +121 -0
- package/tsconfig.json +10 -0
- package/types/@audius-hedgehog/index.d.ts +39 -0
- package/types/abi-decoder/index.d.ts +41 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
const helpers = require('./helpers')
|
|
2
|
+
const assert = require('assert')
|
|
3
|
+
const { convertAudsToWeiBN } = require('../initScripts/helpers/utils')
|
|
4
|
+
const nock = require('nock')
|
|
5
|
+
const { Vote } = require('../src/services/ethContracts/GovernanceClient')
|
|
6
|
+
const time = require('@openzeppelin/test-helpers/src/time')
|
|
7
|
+
const { initializeLibConfig } = require('./helpers')
|
|
8
|
+
const AudiusLibs = require('../src')
|
|
9
|
+
|
|
10
|
+
const { audiusInstance: audius0, getRandomLocalhost } = helpers
|
|
11
|
+
|
|
12
|
+
let audius1
|
|
13
|
+
let audius2
|
|
14
|
+
let accounts = null
|
|
15
|
+
let web3 = null
|
|
16
|
+
let toBN = null
|
|
17
|
+
let sp1
|
|
18
|
+
let sp2
|
|
19
|
+
const DEFAULT_STAKE = 210000
|
|
20
|
+
const PROPOSAL_DESCRIPTION = 'TestDescription'
|
|
21
|
+
const PROPOSAL_NAME = 'TestName'
|
|
22
|
+
const testServiceType = 'discovery-provider'
|
|
23
|
+
|
|
24
|
+
const setupAccounts = async () => {
|
|
25
|
+
// create additional libs instances
|
|
26
|
+
await audius0.init()
|
|
27
|
+
web3 = audius0.ethWeb3Manager.getWeb3()
|
|
28
|
+
toBN = web3.utils.toBN
|
|
29
|
+
accounts = await web3.eth.getAccounts()
|
|
30
|
+
sp1 = accounts[1]
|
|
31
|
+
sp2 = accounts[2]
|
|
32
|
+
const libsConf1 = await initializeLibConfig(sp1)
|
|
33
|
+
const libsConf2 = await initializeLibConfig(sp2)
|
|
34
|
+
audius1 = new AudiusLibs(libsConf1)
|
|
35
|
+
audius2 = new AudiusLibs(libsConf2)
|
|
36
|
+
|
|
37
|
+
// Init them all
|
|
38
|
+
await Promise.all([audius1.init(), audius2.init()])
|
|
39
|
+
|
|
40
|
+
// Register endpoints & stake
|
|
41
|
+
const inittedLibs = [audius0, audius1, audius2]
|
|
42
|
+
const defaultStake = convertAudsToWeiBN(
|
|
43
|
+
audius0.ethWeb3Manager.getWeb3(),
|
|
44
|
+
DEFAULT_STAKE
|
|
45
|
+
)
|
|
46
|
+
for (const lib of inittedLibs) {
|
|
47
|
+
const testEndpoint = getRandomLocalhost()
|
|
48
|
+
nock(testEndpoint)
|
|
49
|
+
.get('/health_check')
|
|
50
|
+
.reply(200, {
|
|
51
|
+
data: {
|
|
52
|
+
service: testServiceType,
|
|
53
|
+
version: '0.0.1'
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
await lib.ethContracts.ServiceProviderFactoryClient.register(
|
|
58
|
+
testServiceType,
|
|
59
|
+
testEndpoint,
|
|
60
|
+
defaultStake
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const cleanupAccounts = async () => {
|
|
66
|
+
try {
|
|
67
|
+
await helpers.deregisterSPEndpoint(audius1, sp1, testServiceType)
|
|
68
|
+
await helpers.deregisterSPEndpoint(audius2, sp2, testServiceType)
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.error(e)
|
|
71
|
+
// no-op -- was already registered
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const createProposal = () => {
|
|
76
|
+
const targetContractRegistryKey = web3.utils.utf8ToHex('DelegateManager')
|
|
77
|
+
|
|
78
|
+
const callValue = web3.utils.toWei('0', 'ether')
|
|
79
|
+
const functionSignature = 'slash(uint256,address)'
|
|
80
|
+
const slashAmount = web3.utils.toWei('500', 'ether')
|
|
81
|
+
const targetAddress = accounts[1]
|
|
82
|
+
const callData = [slashAmount, targetAddress]
|
|
83
|
+
const description = PROPOSAL_DESCRIPTION
|
|
84
|
+
const name = PROPOSAL_NAME
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
targetContractRegistryKey,
|
|
88
|
+
callValue,
|
|
89
|
+
functionSignature,
|
|
90
|
+
callData,
|
|
91
|
+
name,
|
|
92
|
+
description
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const submitProposal = async () => {
|
|
97
|
+
const proposal = createProposal()
|
|
98
|
+
return audius0.ethContracts.GovernanceClient.submitProposal(proposal)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const evaluateProposal = async (id, shouldVote = true) => {
|
|
102
|
+
// Vote
|
|
103
|
+
if (shouldVote) {
|
|
104
|
+
const voteYes = Vote.yes
|
|
105
|
+
await audius0.ethContracts.GovernanceClient.submitVote({
|
|
106
|
+
proposalId: id,
|
|
107
|
+
vote: voteYes
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Advance blocks
|
|
112
|
+
const currentBlock = (await web3.eth.getBlock('latest')).number
|
|
113
|
+
const desired = currentBlock + 20
|
|
114
|
+
await time.advanceBlockTo(desired)
|
|
115
|
+
|
|
116
|
+
// Evaluate
|
|
117
|
+
await audius0.ethContracts.GovernanceClient.evaluateProposalOutcome(id)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
describe('Governance tests', function () {
|
|
121
|
+
this.timeout(5000)
|
|
122
|
+
|
|
123
|
+
before(async function () {
|
|
124
|
+
await setupAccounts()
|
|
125
|
+
await audius0.ethContracts.GovernanceClient.setVotingPeriod(10)
|
|
126
|
+
await audius0.ethContracts.GovernanceClient.setExecutionDelay(10)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
afterEach(async function () {
|
|
130
|
+
// Cleanup outstanding proposals
|
|
131
|
+
const ids =
|
|
132
|
+
await audius0.ethContracts.GovernanceClient.getInProgressProposals()
|
|
133
|
+
for (let id of ids) {
|
|
134
|
+
await evaluateProposal(id, false)
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
after(async function () {
|
|
139
|
+
await cleanupAccounts()
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('Submits a proposal successfully', async function () {
|
|
143
|
+
const id = await submitProposal()
|
|
144
|
+
assert.ok(id >= 0)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('Gets submitted proposal by ID', async function () {
|
|
148
|
+
// Submit the proposal
|
|
149
|
+
const id = await submitProposal()
|
|
150
|
+
const proposal =
|
|
151
|
+
await audius0.ethContracts.GovernanceClient.getProposalById(id)
|
|
152
|
+
|
|
153
|
+
// Sanity check proposal
|
|
154
|
+
assert.equal(proposal.proposalId, id)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('Votes on proposals', async function () {
|
|
158
|
+
const id = await submitProposal()
|
|
159
|
+
|
|
160
|
+
// Submit a yes vote initially
|
|
161
|
+
const voteYes = Vote.yes
|
|
162
|
+
await audius0.ethContracts.GovernanceClient.submitVote({
|
|
163
|
+
proposalId: id,
|
|
164
|
+
vote: voteYes
|
|
165
|
+
})
|
|
166
|
+
const proposal =
|
|
167
|
+
await audius0.ethContracts.GovernanceClient.getProposalById(id)
|
|
168
|
+
const bnZero = toBN(0)
|
|
169
|
+
assert.ok(proposal.voteMagnitudeNo.eq(bnZero))
|
|
170
|
+
assert.ok(proposal.voteMagnitudeYes.gt(bnZero))
|
|
171
|
+
|
|
172
|
+
// Update the vote to be 'no'
|
|
173
|
+
const voteNo = Vote.no
|
|
174
|
+
await audius0.ethContracts.GovernanceClient.updateVote({
|
|
175
|
+
proposalId: id,
|
|
176
|
+
vote: voteNo
|
|
177
|
+
})
|
|
178
|
+
const proposal2 =
|
|
179
|
+
await audius0.ethContracts.GovernanceClient.getProposalById(id)
|
|
180
|
+
assert.ok(proposal2.voteMagnitudeYes.eq(bnZero))
|
|
181
|
+
assert.ok(proposal2.voteMagnitudeNo.gt(bnZero))
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('Queries for votes', async function () {
|
|
185
|
+
const id = await submitProposal()
|
|
186
|
+
const proposal =
|
|
187
|
+
await audius0.ethContracts.GovernanceClient.getProposalById(id)
|
|
188
|
+
const queryStartBlock = proposal.submissionBlockNumber
|
|
189
|
+
// Test for vote creation
|
|
190
|
+
const voteYes = Vote.yes
|
|
191
|
+
await audius0.ethContracts.GovernanceClient.submitVote({
|
|
192
|
+
proposalId: id,
|
|
193
|
+
vote: voteYes
|
|
194
|
+
})
|
|
195
|
+
const votes = await audius0.ethContracts.GovernanceClient.getVotes({
|
|
196
|
+
proposalId: id,
|
|
197
|
+
queryStartBlock
|
|
198
|
+
})
|
|
199
|
+
assert.equal(votes.length, 1)
|
|
200
|
+
assert.equal(votes[0].vote, 2)
|
|
201
|
+
|
|
202
|
+
// Test for vote update
|
|
203
|
+
const voteNo = Vote.no
|
|
204
|
+
await audius0.ethContracts.GovernanceClient.updateVote({
|
|
205
|
+
proposalId: id,
|
|
206
|
+
vote: voteNo
|
|
207
|
+
})
|
|
208
|
+
const updateVotes =
|
|
209
|
+
await audius0.ethContracts.GovernanceClient.getVoteUpdates({
|
|
210
|
+
proposalId: id,
|
|
211
|
+
queryStartBlock
|
|
212
|
+
})
|
|
213
|
+
assert.equal(updateVotes.length, 1)
|
|
214
|
+
assert.equal(updateVotes[0].vote, 1)
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it('Gets in progress proposals', async function () {
|
|
218
|
+
const id = await submitProposal()
|
|
219
|
+
const inProgressIds =
|
|
220
|
+
await audius0.ethContracts.GovernanceClient.getInProgressProposals()
|
|
221
|
+
assert.equal(inProgressIds.length, 1)
|
|
222
|
+
assert.equal(inProgressIds[0], id)
|
|
223
|
+
|
|
224
|
+
// evaluate
|
|
225
|
+
await evaluateProposal(id)
|
|
226
|
+
const inProgressIds2 =
|
|
227
|
+
await audius0.ethContracts.GovernanceClient.getInProgressProposals()
|
|
228
|
+
assert.equal(inProgressIds2.length, 0)
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
it('Gets all proposals', async function () {
|
|
232
|
+
const blockNumber = await audius0.ethWeb3Manager
|
|
233
|
+
.getWeb3()
|
|
234
|
+
.eth.getBlockNumber()
|
|
235
|
+
|
|
236
|
+
const id = await submitProposal()
|
|
237
|
+
const inProgressIds =
|
|
238
|
+
await audius0.ethContracts.GovernanceClient.getProposals(blockNumber)
|
|
239
|
+
assert.equal(inProgressIds.length, 1)
|
|
240
|
+
assert.equal(inProgressIds[0].proposalId, id)
|
|
241
|
+
|
|
242
|
+
// evaluate
|
|
243
|
+
await evaluateProposal(id)
|
|
244
|
+
const inProgressIds2 =
|
|
245
|
+
await audius0.ethContracts.GovernanceClient.getProposals(blockNumber)
|
|
246
|
+
assert.equal(inProgressIds.length, 1)
|
|
247
|
+
assert.equal(inProgressIds[0].proposalId, id)
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
it('Gets a proposal evaluation', async function () {
|
|
251
|
+
const blockNumber = await audius0.ethWeb3Manager
|
|
252
|
+
.getWeb3()
|
|
253
|
+
.eth.getBlockNumber()
|
|
254
|
+
|
|
255
|
+
const id = await submitProposal()
|
|
256
|
+
await evaluateProposal(id)
|
|
257
|
+
const evaluation =
|
|
258
|
+
await audius0.ethContracts.GovernanceClient.getProposalEvaluation(id)
|
|
259
|
+
assert.equal(evaluation.length, 1)
|
|
260
|
+
assert.equal(evaluation[0].returnValues._numVotes, '1')
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
it('Gets a proposal submisson', async function () {
|
|
264
|
+
const blockNumber = await audius0.ethWeb3Manager
|
|
265
|
+
.getWeb3()
|
|
266
|
+
.eth.getBlockNumber()
|
|
267
|
+
|
|
268
|
+
const id = await submitProposal()
|
|
269
|
+
const submission =
|
|
270
|
+
await audius0.ethContracts.GovernanceClient.getProposalSubmission(id)
|
|
271
|
+
assert.equal(submission.description, PROPOSAL_DESCRIPTION)
|
|
272
|
+
assert.equal(submission.name, PROPOSAL_NAME)
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
it('Gets votes by address', async function () {
|
|
276
|
+
const id = await submitProposal()
|
|
277
|
+
const proposal =
|
|
278
|
+
await audius0.ethContracts.GovernanceClient.getProposalById(id)
|
|
279
|
+
const queryStartBlock = proposal.submissionBlockNumber
|
|
280
|
+
|
|
281
|
+
// submit votes
|
|
282
|
+
const voteYes = Vote.yes
|
|
283
|
+
const voteNo = Vote.no
|
|
284
|
+
await audius1.ethContracts.GovernanceClient.submitVote({
|
|
285
|
+
proposalId: id,
|
|
286
|
+
vote: voteYes
|
|
287
|
+
})
|
|
288
|
+
await audius2.ethContracts.GovernanceClient.submitVote({
|
|
289
|
+
proposalId: id,
|
|
290
|
+
vote: voteNo
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
// update some votes
|
|
294
|
+
await audius1.ethContracts.GovernanceClient.updateVote({
|
|
295
|
+
proposalId: id,
|
|
296
|
+
vote: voteNo
|
|
297
|
+
})
|
|
298
|
+
await audius2.ethContracts.GovernanceClient.updateVote({
|
|
299
|
+
proposalId: id,
|
|
300
|
+
vote: voteYes
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
// get submissions and updates
|
|
304
|
+
const account1Submissions =
|
|
305
|
+
await audius0.ethContracts.GovernanceClient.getVoteSubmissionsByAddress({
|
|
306
|
+
addresses: [accounts[1]],
|
|
307
|
+
queryStartBlock
|
|
308
|
+
})
|
|
309
|
+
const account2Updates =
|
|
310
|
+
await audius0.ethContracts.GovernanceClient.getVoteUpdatesByAddress({
|
|
311
|
+
addresses: [accounts[2]],
|
|
312
|
+
queryStartBlock
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
// assert filters work correctly
|
|
316
|
+
assert.equal(account1Submissions.length, 1)
|
|
317
|
+
assert.equal(account1Submissions[0].voter, accounts[1])
|
|
318
|
+
assert.equal(account2Updates.length, 1)
|
|
319
|
+
assert.equal(account2Updates[0].voter, accounts[2])
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
it('Gets Quorum Percent', async function () {
|
|
323
|
+
const percent =
|
|
324
|
+
await audius0.ethContracts.GovernanceClient.getVotingQuorumPercent()
|
|
325
|
+
assert.ok(typeof percent === 'number')
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
it('Gets voting period', async function () {
|
|
329
|
+
const period = await audius0.ethContracts.GovernanceClient.getVotingPeriod()
|
|
330
|
+
assert.ok(typeof period === 'number')
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
it('Gets execution delay', async function () {
|
|
334
|
+
const delay =
|
|
335
|
+
await audius0.ethContracts.GovernanceClient.getExecutionDelay()
|
|
336
|
+
assert.ok(typeof delay === 'number')
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
it('Gets target contract hash', async function () {
|
|
340
|
+
const id = await submitProposal()
|
|
341
|
+
const hash =
|
|
342
|
+
await audius0.ethContracts.GovernanceClient.getProposalTargetContractHash(
|
|
343
|
+
id
|
|
344
|
+
)
|
|
345
|
+
assert.ok(typeof hash === 'string')
|
|
346
|
+
assert.ok(hash.length > 0)
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
it('Gets vote by proposal and voter', async function () {
|
|
350
|
+
const id = await submitProposal()
|
|
351
|
+
|
|
352
|
+
// submit yes votes
|
|
353
|
+
const voteYes = Vote.yes
|
|
354
|
+
const voteNo = Vote.no
|
|
355
|
+
await audius1.ethContracts.GovernanceClient.submitVote({
|
|
356
|
+
proposalId: id,
|
|
357
|
+
vote: voteYes
|
|
358
|
+
})
|
|
359
|
+
const result =
|
|
360
|
+
await audius0.ethContracts.GovernanceClient.getVoteByProposalAndVoter({
|
|
361
|
+
proposalId: id,
|
|
362
|
+
voterAddress: accounts[1]
|
|
363
|
+
})
|
|
364
|
+
assert.equal(result, 2)
|
|
365
|
+
|
|
366
|
+
// submit yes vote, update to no vote
|
|
367
|
+
await audius2.ethContracts.GovernanceClient.submitVote({
|
|
368
|
+
proposalId: id,
|
|
369
|
+
vote: voteYes
|
|
370
|
+
})
|
|
371
|
+
await audius2.ethContracts.GovernanceClient.updateVote({
|
|
372
|
+
proposalId: id,
|
|
373
|
+
vote: voteNo
|
|
374
|
+
})
|
|
375
|
+
const result2 =
|
|
376
|
+
await audius0.ethContracts.GovernanceClient.getVoteByProposalAndVoter({
|
|
377
|
+
proposalId: id,
|
|
378
|
+
voterAddress: accounts[2]
|
|
379
|
+
})
|
|
380
|
+
assert.equal(result2, 1)
|
|
381
|
+
})
|
|
382
|
+
})
|
package/tests/helpers.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const nock = require('nock')
|
|
2
|
+
|
|
3
|
+
const Web3 = require('../src/web3')
|
|
4
|
+
const AudiusLibs = require('../src/index')
|
|
5
|
+
const dataContractsConfig = require('../data-contracts/config.json')
|
|
6
|
+
const ethContractsConfig = require('../eth-contracts/config.json')
|
|
7
|
+
|
|
8
|
+
const creatorNodeEndpoint = 'http://localhost:4000'
|
|
9
|
+
const discoveryProviderEndpoint = 'http://localhost:5000'
|
|
10
|
+
const identityServiceEndpoint = 'http://localhost:7000'
|
|
11
|
+
const dataWeb3ProviderEndpoint = 'http://localhost:8545'
|
|
12
|
+
const ethWeb3ProviderEndpoint = 'http://localhost:8546'
|
|
13
|
+
require('@openzeppelin/test-helpers/configure')({
|
|
14
|
+
provider: ethWeb3ProviderEndpoint,
|
|
15
|
+
})
|
|
16
|
+
const isServer = true
|
|
17
|
+
|
|
18
|
+
const constants = {
|
|
19
|
+
trackMetadataCID: 'QmSH5gJPHg9xLzV823ty8BSGyHNP6ty22bgLsv5MLY3kBq',
|
|
20
|
+
trackMetadataCID2: 'QmSH5gJPHg9xLzV823ty8BSGyHNP6ty22bgLaaaaaaaaaa',
|
|
21
|
+
creatorMetadataCID: 'QmTDhoEDLE3k3CE5bu4mF1ogsEVkPwEAM41KsN7hZX1eWY',
|
|
22
|
+
'0x0': '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
23
|
+
creatorNodeURL1: 'http://localhost:8000/',
|
|
24
|
+
creatorNodeURL2: 'http://localhost:8001/',
|
|
25
|
+
signatureData: 'Click sign to authenticate with creator node:1543885912',
|
|
26
|
+
signatureAddress: '0x7d267e2f8dc64c53267c56dab55bf7050566baec',
|
|
27
|
+
signature: '0xbb3ffe5f32950ace5c0a8ecb9c43ab836b7b7146a56e2519ac1c662e9b00bdcd7de9a3f3265206c54f0b8094f8ac8832d32d5852492c1aa3e9493e28ae3a31b91b',
|
|
28
|
+
wallet: '0xdfdbe819b5710b750b3a00eb2fae8a59b85c66af',
|
|
29
|
+
ethContractsConfig: ethContractsConfig
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const dataWeb3 = new Web3(new Web3.providers.HttpProvider(dataWeb3ProviderEndpoint))
|
|
33
|
+
const ethWeb3 = new Web3(new Web3.providers.HttpProvider(ethWeb3ProviderEndpoint))
|
|
34
|
+
|
|
35
|
+
const audiusLibsConfig = {
|
|
36
|
+
web3Config: AudiusLibs.configExternalWeb3(
|
|
37
|
+
dataContractsConfig.registryAddress,
|
|
38
|
+
dataWeb3
|
|
39
|
+
),
|
|
40
|
+
ethWeb3Config: AudiusLibs.configEthWeb3(
|
|
41
|
+
ethContractsConfig.audiusTokenAddress,
|
|
42
|
+
ethContractsConfig.registryAddress,
|
|
43
|
+
ethWeb3,
|
|
44
|
+
ethContractsConfig.ownerWallet
|
|
45
|
+
),
|
|
46
|
+
isServer: true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function initializeLibConfig (ownerWallet) {
|
|
50
|
+
return {
|
|
51
|
+
web3Config: AudiusLibs.configExternalWeb3(
|
|
52
|
+
dataContractsConfig.registryAddress,
|
|
53
|
+
dataWeb3
|
|
54
|
+
),
|
|
55
|
+
ethWeb3Config: AudiusLibs.configEthWeb3(
|
|
56
|
+
ethContractsConfig.audiusTokenAddress,
|
|
57
|
+
ethContractsConfig.registryAddress,
|
|
58
|
+
ethWeb3,
|
|
59
|
+
ownerWallet
|
|
60
|
+
),
|
|
61
|
+
isServer: true
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const getRandomLocalhost = () => {
|
|
66
|
+
return 'https://localhost:' + Math.floor(1000 + Math.random() * 9000)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const deregisterSPEndpoint = async (libs, account, type) => {
|
|
70
|
+
let previousRegisteredId = await libs.ethContracts.ServiceProviderFactoryClient.getServiceProviderIdFromAddress(
|
|
71
|
+
account,
|
|
72
|
+
type)
|
|
73
|
+
let prevSpInfo = await libs.ethContracts.ServiceProviderFactoryClient.getServiceEndpointInfo(
|
|
74
|
+
type,
|
|
75
|
+
previousRegisteredId)
|
|
76
|
+
|
|
77
|
+
let path = '/version'
|
|
78
|
+
let response = {
|
|
79
|
+
service: type,
|
|
80
|
+
version : '0.0.1'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (type === 'discovery-provider') {
|
|
84
|
+
path = '/health_check'
|
|
85
|
+
response = {data: {...response}}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
nock(prevSpInfo.endpoint)
|
|
89
|
+
.get(path)
|
|
90
|
+
.reply(200, response)
|
|
91
|
+
let tx = await libs.ethContracts.ServiceProviderFactoryClient.deregister(
|
|
92
|
+
type,
|
|
93
|
+
prevSpInfo.endpoint)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
module.exports = {
|
|
97
|
+
constants,
|
|
98
|
+
// Export configured libs instance
|
|
99
|
+
audiusInstance: new AudiusLibs(audiusLibsConfig),
|
|
100
|
+
// Export libs config for re-use
|
|
101
|
+
audiusLibsConfig,
|
|
102
|
+
initializeLibConfig,
|
|
103
|
+
getRandomLocalhost,
|
|
104
|
+
deregisterSPEndpoint
|
|
105
|
+
}
|
package/tests/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require('./helpers')
|
|
2
|
+
require('./registryClientTest')
|
|
3
|
+
require('./userClientTest')
|
|
4
|
+
require('./creatorNodeTest')
|
|
5
|
+
require('./trackClientTest')
|
|
6
|
+
require('./playlistClientTest')
|
|
7
|
+
require('./socialFeatureClientTest')
|
|
8
|
+
require('./serviceTypeManagerClientTest')
|
|
9
|
+
require('./audiusTokenClientTest')
|
|
10
|
+
require('./stakingTest')
|
|
11
|
+
require('./providerSelectionTest')
|
|
12
|
+
require('./governanceTest')
|
|
13
|
+
require('./rewardsAttesterTest')
|
|
14
|
+
require('./fileHasherTest')
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
let helpers = require('./helpers')
|
|
3
|
+
let {Utils} = require('../src/utils')
|
|
4
|
+
|
|
5
|
+
let audiusInstance = helpers.audiusInstance
|
|
6
|
+
let playlistOwnerId
|
|
7
|
+
|
|
8
|
+
// First created playlist
|
|
9
|
+
let playlistId = 1
|
|
10
|
+
|
|
11
|
+
// Initial tracks
|
|
12
|
+
let playlistTracks = []
|
|
13
|
+
|
|
14
|
+
// Initial playlist configuration
|
|
15
|
+
let initialPlaylistName = 'Test playlist name'
|
|
16
|
+
let initialIsPrivate = false
|
|
17
|
+
|
|
18
|
+
before(async function () {
|
|
19
|
+
await audiusInstance.init()
|
|
20
|
+
playlistOwnerId = (await audiusInstance.contracts.UserFactoryClient.addUser('playlistH')).userId
|
|
21
|
+
|
|
22
|
+
const cid = helpers.constants.trackMetadataCID // test metadata stored in DHT
|
|
23
|
+
const trackMultihashDecoded = Utils.decodeMultihash(cid)
|
|
24
|
+
playlistTracks.push((await audiusInstance.contracts.TrackFactoryClient.addTrack(
|
|
25
|
+
playlistOwnerId,
|
|
26
|
+
trackMultihashDecoded.digest,
|
|
27
|
+
trackMultihashDecoded.hashFn,
|
|
28
|
+
trackMultihashDecoded.size
|
|
29
|
+
)).trackId)
|
|
30
|
+
playlistTracks.push((await audiusInstance.contracts.TrackFactoryClient.addTrack(
|
|
31
|
+
playlistOwnerId,
|
|
32
|
+
trackMultihashDecoded.digest,
|
|
33
|
+
trackMultihashDecoded.hashFn,
|
|
34
|
+
trackMultihashDecoded.size
|
|
35
|
+
)).trackId)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// TODO: Add validation to the below test cases, currently they just perform chain operations.
|
|
39
|
+
|
|
40
|
+
it('should create playlist', async function () {
|
|
41
|
+
const playlistId = await audiusInstance.contracts.PlaylistFactoryClient.createPlaylist(
|
|
42
|
+
playlistOwnerId,
|
|
43
|
+
initialPlaylistName,
|
|
44
|
+
initialIsPrivate,
|
|
45
|
+
false,
|
|
46
|
+
playlistTracks)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should create album', async function () {
|
|
50
|
+
const playlistId = await audiusInstance.contracts.PlaylistFactoryClient.createPlaylist(
|
|
51
|
+
playlistOwnerId,
|
|
52
|
+
initialPlaylistName,
|
|
53
|
+
initialIsPrivate,
|
|
54
|
+
true,
|
|
55
|
+
playlistTracks)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should create and delete playlist', async function () {
|
|
59
|
+
// create playlist
|
|
60
|
+
const { playlistId } = await audiusInstance.contracts.PlaylistFactoryClient.createPlaylist(
|
|
61
|
+
playlistOwnerId,
|
|
62
|
+
initialPlaylistName,
|
|
63
|
+
initialIsPrivate,
|
|
64
|
+
false,
|
|
65
|
+
playlistTracks)
|
|
66
|
+
|
|
67
|
+
// delete playlist + validate
|
|
68
|
+
const { playlistId: deletedPlaylistId } = await audiusInstance.contracts.PlaylistFactoryClient.deletePlaylist(playlistId)
|
|
69
|
+
assert.strictEqual(playlistId, deletedPlaylistId)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should add tracks to an existing playlist', async function () {
|
|
73
|
+
const cid = helpers.constants.trackMetadataCID // test metadata stored in DHT
|
|
74
|
+
const trackMultihashDecoded = Utils.decodeMultihash(cid)
|
|
75
|
+
|
|
76
|
+
// Add a new track
|
|
77
|
+
const { trackId } = await audiusInstance.contracts.TrackFactoryClient.addTrack(
|
|
78
|
+
playlistOwnerId,
|
|
79
|
+
trackMultihashDecoded.digest,
|
|
80
|
+
trackMultihashDecoded.hashFn,
|
|
81
|
+
trackMultihashDecoded.size
|
|
82
|
+
)
|
|
83
|
+
const track = await audiusInstance.contracts.TrackFactoryClient.getTrack(trackId)
|
|
84
|
+
assert.strictEqual(track.multihashDigest, trackMultihashDecoded.digest)
|
|
85
|
+
|
|
86
|
+
const addPlaylistTrackTx = await audiusInstance.contracts.PlaylistFactoryClient.addPlaylistTrack(
|
|
87
|
+
playlistId,
|
|
88
|
+
trackId)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('should delete track from an existing playlist', async function () {
|
|
92
|
+
const cid = helpers.constants.trackMetadataCID // test metadata stored in DHT
|
|
93
|
+
const trackMultihashDecoded = Utils.decodeMultihash(cid)
|
|
94
|
+
|
|
95
|
+
// Add a new track
|
|
96
|
+
const { trackId } = await audiusInstance.contracts.TrackFactoryClient.addTrack(
|
|
97
|
+
playlistOwnerId,
|
|
98
|
+
trackMultihashDecoded.digest,
|
|
99
|
+
trackMultihashDecoded.hashFn,
|
|
100
|
+
trackMultihashDecoded.size
|
|
101
|
+
)
|
|
102
|
+
const track = await audiusInstance.contracts.TrackFactoryClient.getTrack(trackId)
|
|
103
|
+
assert.strictEqual(track.multihashDigest, trackMultihashDecoded.digest)
|
|
104
|
+
|
|
105
|
+
const addPlaylistTrackTx = await audiusInstance.contracts.PlaylistFactoryClient.addPlaylistTrack(
|
|
106
|
+
playlistId,
|
|
107
|
+
trackId)
|
|
108
|
+
|
|
109
|
+
const deletedTimestamp = 1552008725
|
|
110
|
+
// Delete the newly added track from the playlist
|
|
111
|
+
const deletedPlaylistTrackTx = await audiusInstance.contracts.PlaylistFactoryClient.deletePlaylistTrack(
|
|
112
|
+
playlistId,
|
|
113
|
+
trackId,
|
|
114
|
+
deletedTimestamp)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('should reorder tracks in an existing playlist', async function () {
|
|
118
|
+
playlistTracks.push(playlistTracks.shift()) // put first element at end
|
|
119
|
+
const orderTracksTx = await audiusInstance.contracts.PlaylistFactoryClient.orderPlaylistTracks(
|
|
120
|
+
playlistId,
|
|
121
|
+
playlistTracks)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('should update playlist privacy', async function () {
|
|
125
|
+
const updatedPrivacy = false
|
|
126
|
+
const updatePlaylistPrivacyTx = await audiusInstance.contracts.PlaylistFactoryClient.updatePlaylistPrivacy(
|
|
127
|
+
playlistId,
|
|
128
|
+
updatedPrivacy)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('should update playlist name', async function () {
|
|
132
|
+
const updatedPlaylistName = 'Here is my updated playlist name'
|
|
133
|
+
const updatePlaylistNameTx = await audiusInstance.contracts.PlaylistFactoryClient.updatePlaylistName(
|
|
134
|
+
playlistId,
|
|
135
|
+
updatedPlaylistName)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it('should update playlist cover photo', async function () {
|
|
139
|
+
const cid = helpers.constants.trackMetadataCID // test metadata stored in DHT
|
|
140
|
+
const trackMultihashDecoded = Utils.decodeMultihash(cid)
|
|
141
|
+
const testPhotoDigest = trackMultihashDecoded.digest
|
|
142
|
+
const updatePlaylistCoverPhotoTx = await audiusInstance.contracts.PlaylistFactoryClient.updatePlaylistCoverPhoto(
|
|
143
|
+
playlistId,
|
|
144
|
+
testPhotoDigest)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('should update playlist description', async function () {
|
|
148
|
+
const description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis'
|
|
149
|
+
const updatePlaylistDescriptionTx = await audiusInstance.contracts.PlaylistFactoryClient.updatePlaylistDescription(
|
|
150
|
+
playlistId,
|
|
151
|
+
description)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('should update playlist UPC', async function () {
|
|
155
|
+
const newUPC = '928152343234'
|
|
156
|
+
const updatePlaylistUPC = await audiusInstance.contracts.PlaylistFactoryClient.updatePlaylistUPC(playlistId, newUPC)
|
|
157
|
+
})
|