{"id":2287,"date":"2019-01-11T08:23:57","date_gmt":"2019-01-10T19:23:57","guid":{"rendered":"http:\/\/www.talkcrypto.org\/blog\/?p=2287"},"modified":"2019-02-20T19:09:11","modified_gmt":"2019-02-20T06:09:11","slug":"where-is-deployedaddresses-sol-when-testing-in-truffle","status":"publish","type":"post","link":"https:\/\/www.talkcrypto.org\/blog\/2019\/01\/11\/where-is-deployedaddresses-sol-when-testing-in-truffle\/","title":{"rendered":"Where is DeployedAddresses.sol?"},"content":{"rendered":"<p>If you are creating test scripts in solidity, you may have come across these import statement:<\/p>\n<pre>import \"truffle\/Assert.sol\";\nimport \"truffle\/DeployedAddresses.sol\";\nimport \"..\/contracts\/HelloWorld.sol\";<\/pre>\n<p>The last one is easy to understand because it is your smart contract in the &#8220;contracts&#8221; folder but what about Assert.sol and&nbsp;DeployedAddresses.sol?<\/p>\n<p>First of all, &#8220;truffle&#8221; refers to the global truffle repo which can be found at usr\/local\/lib\/node_modules\/truffle.<\/p>\n<p>Assert.sol lives at:&nbsp;usr\/local\/lib\/node_modules\/truffle\/build\/Assert.sol<\/p>\n<p><a href=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.12.14-am.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-2288 size-full\" src=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.12.14-am.png\" alt=\"\" width=\"988\" height=\"104\" srcset=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.12.14-am.png 988w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.12.14-am-300x32.png 300w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.12.14-am-768x81.png 768w\" sizes=\"(max-width: 988px) 100vw, 988px\" \/><\/a><\/p>\n<p>The trick is, what about&nbsp;DeployedAddresses.sol? You won&#8217;t find this file in the global truffle repo and a terminal search will be <del>chocolateless<\/del> fruitless.<\/p>\n<p><a href=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.13.12-am.png\"><img decoding=\"async\" class=\"alignnone wp-image-2289 size-full\" src=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.13.12-am.png\" alt=\"\" width=\"1118\" height=\"142\" srcset=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.13.12-am.png 1118w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.13.12-am-300x38.png 300w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.13.12-am-768x98.png 768w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.13.12-am-1024x130.png 1024w\" sizes=\"(max-width: 1118px) 100vw, 1118px\" \/><\/a><\/p>\n<p>The reason is because this file is dynamically created at test time. (Kindalike the geth.ipc file that gets generated when geth is running but disappears when geth is stopped).<\/p>\n<p>&#8220;truffle&#8221; is a <a href=\"https:\/\/github.com\/trufflesuite\/truffle\/issues\/471\" target=\"_blank\" rel=\"noopener\">meta package<\/a>, ie &#8220;<a href=\"https:\/\/askubuntu.com\/questions\/66257\/what-is-the-difference-between-a-meta-package-and-a-package\" target=\"_blank\" rel=\"noopener\">these packages do not contain actual software, they simply depend on other packages to be installed<\/a>&#8220;. In fact, if you look at the <a href=\"https:\/\/github.com\/trufflesuite\/truffle-core\/blob\/b3ad375993ec42bc622c7674258edc7614944482\/lib\/testing\/deployed.js\" target=\"_blank\" rel=\"noopener\">deploy.js<\/a> source code, you&#8217;ll see the&nbsp;DeployedAddresses file get created via the code.<\/p>\n<p><a href=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.20.50-am.png\"><img decoding=\"async\" class=\"alignnone wp-image-2290 size-large\" src=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.20.50-am-1024x491.png\" alt=\"\" width=\"940\" height=\"451\" srcset=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.20.50-am-1024x491.png 1024w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.20.50-am-300x144.png 300w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.20.50-am-768x368.png 768w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-11-at-8.20.50-am.png 1624w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/p>\n<p>Source:<\/p>\n<ul>\n<li>https:\/\/github.com\/trufflesuite\/truffle\/issues\/471<\/li>\n<li>https:\/\/github.com\/trufflesuite\/truffle-core\/blob\/b3ad375993ec42bc622c7674258edc7614944482\/lib\/testing\/deployed.js<\/li>\n<li>https:\/\/askubuntu.com\/questions\/66257\/what-is-the-difference-between-a-meta-package-and-a-package<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>If you are creating test scripts in solidity, you may<\/p>\n","protected":false},"author":1,"featured_media":2291,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ethereum"],"featured_image_urls":{"full":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest.jpg",300,153,false],"thumbnail":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest-150x150.jpg",150,150,true],"medium":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest-300x153.jpg",300,153,true],"medium_large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest.jpg",300,153,false],"large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest.jpg",300,153,false],"1536x1536":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest.jpg",300,153,false],"2048x2048":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest.jpg",300,153,false],"chromenews-featured":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest.jpg",300,153,false],"chromenews-large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest.jpg",300,153,false],"chromenews-medium":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/01\/truffletest.jpg",300,153,false]},"author_info":{"info":["seandotau"]},"category_info":"<a href=\"https:\/\/www.talkcrypto.org\/blog\/category\/ethereum\/\" rel=\"category tag\">Ethereum<\/a>","tag_info":"Ethereum","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/comments?post=2287"}],"version-history":[{"count":2,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2287\/revisions"}],"predecessor-version":[{"id":2342,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2287\/revisions\/2342"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/media\/2291"}],"wp:attachment":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/media?parent=2287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/categories?post=2287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/tags?post=2287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}